problem with DB2 schema creation with abstration [message #103781] |
Mon, 26 November 2007 11:46  |
Eclipse User |
|
|
|
Hi Martin,
I hae a xsd with abstration and ecore:reference elements. The createSchema
call gives me this error when it runs the SQL created.
ALTER TABLE BOOKDEFINITION ADD CONSTRAINT PBLSHRDFNT_RSRCLNK FOREIGN KEY
(RESOURCELINK) REFERENCES RESOURCELINK (RESOURCELINK_ID) ON DELETE CASCADE
;
DB21034E The command was processed as an SQL statement because it was not
a
valid Command Line Processor command. During SQL processing it returned:
SQL20255N FOREIGN KEY "PBLSHRDFNT" is not valid because it would cause a
descendent table "JULIA.BOOK" to be delete-connected to its ancestor table
"JULIA.RESO" through multiple relationships with conflicting delete rules.
The
conflict is between the delete rules of constraints "JULIA.BOOK" and
"JULIA.BOOKDEFINITION.CHL" on the descendent table. Reason code = "2".
SQLSTATE=42915
The sql statement work if I remove the ON DELETE CASCADE token. Though I'm
not sure that's the correct solution. I have gotten the same error with ON
DELETE RESTRICT. It seem to be related to ecore:reference in an element
that uses substitutionGroup. I have gotten the same error in my bigger xsd
with other similiar elements.
Any thoughts on this?
Julia
Here's my sample xsd
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="0.9.3.0"
xml:lang="en"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:portal=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xs:element name="booksinlib" type="portal:BooksInLib"/>
<xs:complexType name="BooksInLib">
<xs:sequence>
<xs:element name="library" type="portal:Library" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Library">
<xs:sequence>
<xs:element name="library" type="portal:Library" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element ref="portal:abstract-book-definition" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="uniqueName" type="xs:ID"
use="required"/>
</xs:complexType>
<!--
book Definition
-->
<xs:element name="abstract-book-definition"
type="portal:BookDefinition" abstract="true">
</xs:element>
<xs:complexType name="BookDefinition" abstract="true">
<xs:sequence>
<xs:element name="description" type="xs:string" />
<xs:element name="location" type="xs:string" />
</xs:sequence>
<xs:attribute name="uniqueName" type="xs:ID" use="required"/>
</xs:complexType>
<xs:element name="publisher-definition"
type="portal:PublisherDefinition"
substitutionGroup="portal:abstract-book-definition">
</xs:element>
<xs:complexType name="PublisherDefinition">
<xs:complexContent>
<xs:extension base="portal:BookDefinition">
<xs:sequence>
<xs:element name="title" type="xs:string" minOccurs="0"/>
<xs:element name="resource-link"
type="portal:BookDefinitionResourceLink"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="BookDefinitionResourceLink">
<xs:complexContent>
<xs:extension base="portal:ResourceLink">
<xs:attribute name="bookSubject" type="xs:string">
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="ResourceLink" abstract="true">
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="children-books" type="portal:ChildrenBooks"
substitutionGroup="portal:abstract-book-definition">
</xs:element>
<xs:complexType name="ChildrenBooks">
<xs:complexContent>
<xs:extension base="portal:BookDefinition">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="cartoon" type="xs:string"/>
<xs:element name="popup" type="xs:string"/>
</xs:sequence>
<xs:attribute name="publisherDefinitionRef" type="xs:IDREF"
use="required" ecore:reference="portal:PublisherDefinition" >
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="adult-books" type="portal:AdultBooks"
substitutionGroup="portal:abstract-book-definition">
</xs:element>
<xs:complexType name="AdultBooks">
<xs:complexContent>
<xs:extension base="portal:BookDefinition">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="checkedout" type="xs:string"/>
<xs:element name="userid" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
|
|
|
Re: problem with DB2 schema creation with abstration [message #103822 is a reply to message #103781] |
Mon, 26 November 2007 16:27  |
Eclipse User |
|
|
|
Hi Julia,
I checked the db schema on mysql and I could only find one foreign key from bookdefinition to
resourcelink so I am not sure where the message 'multiple relationships' comes from. Do you see more
than one relationship?
Possibly db2 does not allow circular delete cascade relations (guessing here)?
Have you tried the mapping with inheritance mapping strategy set to joined?
gr. Martin
Julia wrote:
> Hi Martin,
>
> I hae a xsd with abstration and ecore:reference elements. The
> createSchema call gives me this error when it runs the SQL created.
>
> ALTER TABLE BOOKDEFINITION ADD CONSTRAINT PBLSHRDFNT_RSRCLNK FOREIGN KEY
> (RESOURCELINK) REFERENCES RESOURCELINK (RESOURCELINK_ID) ON DELETE
> CASCADE ;
>
> DB21034E The command was processed as an SQL statement because it was
> not a valid Command Line Processor command. During SQL processing it
> returned:
> SQL20255N FOREIGN KEY "PBLSHRDFNT" is not valid because it would cause
> a descendent table "JULIA.BOOK" to be delete-connected to its ancestor
> table "JULIA.RESO" through multiple relationships with conflicting
> delete rules. The conflict is between the delete rules of constraints
> "JULIA.BOOK" and "JULIA.BOOKDEFINITION.CHL" on the descendent table.
> Reason code = "2". SQLSTATE=42915
>
> The sql statement work if I remove the ON DELETE CASCADE token. Though
> I'm not sure that's the correct solution. I have gotten the same error
> with ON DELETE RESTRICT. It seem to be related to ecore:reference in an
> element that uses substitutionGroup. I have gotten the same error in my
> bigger xsd with other similiar elements.
>
> Any thoughts on this?
>
> Julia
>
> Here's my sample xsd
> ------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema
> targetNamespace=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
> elementFormDefault="qualified"
> attributeFormDefault="unqualified" version="0.9.3.0"
> xml:lang="en"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:portal=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xlink="http://www.w3.org/1999/xlink">
>
> <xs:element name="booksinlib" type="portal:BooksInLib"/>
> <xs:complexType name="BooksInLib">
> <xs:sequence>
> <xs:element name="library" type="portal:Library"
> maxOccurs="unbounded">
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
> <xs:complexType name="Library">
> <xs:sequence>
> <xs:element name="library" type="portal:Library"
> minOccurs="0" maxOccurs="unbounded"/>
> <xs:element ref="portal:abstract-book-definition"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:ID"
> use="required"/>
> </xs:complexType>
>
> <!-- book Definition
> -->
>
> <xs:element name="abstract-book-definition"
> type="portal:BookDefinition" abstract="true">
> </xs:element>
> <xs:complexType name="BookDefinition" abstract="true">
> <xs:sequence>
> <xs:element name="description" type="xs:string" />
> <xs:element name="location" type="xs:string" />
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:ID" use="required"/>
> </xs:complexType>
>
> <xs:element name="publisher-definition"
> type="portal:PublisherDefinition"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="PublisherDefinition">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string" minOccurs="0"/>
> <xs:element name="resource-link"
> type="portal:BookDefinitionResourceLink"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
>
> </xs:complexType>
>
> <xs:complexType name="BookDefinitionResourceLink">
> <xs:complexContent>
> <xs:extension base="portal:ResourceLink">
> <xs:attribute name="bookSubject" type="xs:string">
> </xs:attribute>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:complexType name="ResourceLink" abstract="true">
> <xs:attribute name="name" type="xs:string" use="required"/>
> </xs:complexType>
>
>
> <xs:element name="children-books" type="portal:ChildrenBooks"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="ChildrenBooks">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string"/>
> <xs:element name="cartoon" type="xs:string"/>
> <xs:element name="popup" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="publisherDefinitionRef"
> type="xs:IDREF" use="required"
> ecore:reference="portal:PublisherDefinition" >
> </xs:attribute>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:element name="adult-books" type="portal:AdultBooks"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="AdultBooks">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string"/>
> <xs:element name="checkedout" type="xs:string"/>
> <xs:element name="userid" type="xs:string"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> </xs:schema>
>
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: problem with DB2 schema creation with abstration [message #612681 is a reply to message #103781] |
Mon, 26 November 2007 16:27  |
Eclipse User |
|
|
|
Hi Julia,
I checked the db schema on mysql and I could only find one foreign key from bookdefinition to
resourcelink so I am not sure where the message 'multiple relationships' comes from. Do you see more
than one relationship?
Possibly db2 does not allow circular delete cascade relations (guessing here)?
Have you tried the mapping with inheritance mapping strategy set to joined?
gr. Martin
Julia wrote:
> Hi Martin,
>
> I hae a xsd with abstration and ecore:reference elements. The
> createSchema call gives me this error when it runs the SQL created.
>
> ALTER TABLE BOOKDEFINITION ADD CONSTRAINT PBLSHRDFNT_RSRCLNK FOREIGN KEY
> (RESOURCELINK) REFERENCES RESOURCELINK (RESOURCELINK_ID) ON DELETE
> CASCADE ;
>
> DB21034E The command was processed as an SQL statement because it was
> not a valid Command Line Processor command. During SQL processing it
> returned:
> SQL20255N FOREIGN KEY "PBLSHRDFNT" is not valid because it would cause
> a descendent table "JULIA.BOOK" to be delete-connected to its ancestor
> table "JULIA.RESO" through multiple relationships with conflicting
> delete rules. The conflict is between the delete rules of constraints
> "JULIA.BOOK" and "JULIA.BOOKDEFINITION.CHL" on the descendent table.
> Reason code = "2". SQLSTATE=42915
>
> The sql statement work if I remove the ON DELETE CASCADE token. Though
> I'm not sure that's the correct solution. I have gotten the same error
> with ON DELETE RESTRICT. It seem to be related to ecore:reference in an
> element that uses substitutionGroup. I have gotten the same error in my
> bigger xsd with other similiar elements.
>
> Any thoughts on this?
>
> Julia
>
> Here's my sample xsd
> ------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema
> targetNamespace=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
> elementFormDefault="qualified"
> attributeFormDefault="unqualified" version="0.9.3.0"
> xml:lang="en"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:portal=" http://www.ibm.com/websphere/appserver/schemas/6.0/ibm-porta l-test.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xlink="http://www.w3.org/1999/xlink">
>
> <xs:element name="booksinlib" type="portal:BooksInLib"/>
> <xs:complexType name="BooksInLib">
> <xs:sequence>
> <xs:element name="library" type="portal:Library"
> maxOccurs="unbounded">
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
> <xs:complexType name="Library">
> <xs:sequence>
> <xs:element name="library" type="portal:Library"
> minOccurs="0" maxOccurs="unbounded"/>
> <xs:element ref="portal:abstract-book-definition"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:ID"
> use="required"/>
> </xs:complexType>
>
> <!-- book Definition
> -->
>
> <xs:element name="abstract-book-definition"
> type="portal:BookDefinition" abstract="true">
> </xs:element>
> <xs:complexType name="BookDefinition" abstract="true">
> <xs:sequence>
> <xs:element name="description" type="xs:string" />
> <xs:element name="location" type="xs:string" />
> </xs:sequence>
> <xs:attribute name="uniqueName" type="xs:ID" use="required"/>
> </xs:complexType>
>
> <xs:element name="publisher-definition"
> type="portal:PublisherDefinition"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="PublisherDefinition">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string" minOccurs="0"/>
> <xs:element name="resource-link"
> type="portal:BookDefinitionResourceLink"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
>
> </xs:complexType>
>
> <xs:complexType name="BookDefinitionResourceLink">
> <xs:complexContent>
> <xs:extension base="portal:ResourceLink">
> <xs:attribute name="bookSubject" type="xs:string">
> </xs:attribute>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:complexType name="ResourceLink" abstract="true">
> <xs:attribute name="name" type="xs:string" use="required"/>
> </xs:complexType>
>
>
> <xs:element name="children-books" type="portal:ChildrenBooks"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="ChildrenBooks">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string"/>
> <xs:element name="cartoon" type="xs:string"/>
> <xs:element name="popup" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="publisherDefinitionRef"
> type="xs:IDREF" use="required"
> ecore:reference="portal:PublisherDefinition" >
> </xs:attribute>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:element name="adult-books" type="portal:AdultBooks"
> substitutionGroup="portal:abstract-book-definition">
> </xs:element>
> <xs:complexType name="AdultBooks">
> <xs:complexContent>
> <xs:extension base="portal:BookDefinition">
> <xs:sequence>
> <xs:element name="title" type="xs:string"/>
> <xs:element name="checkedout" type="xs:string"/>
> <xs:element name="userid" type="xs:string"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> </xs:schema>
>
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.04541 seconds