Home » Modeling » EMF » [Teneo] Different generation using opposite
| | | | |
Re: [Teneo] Different generation using opposite [message #422657 is a reply to message #422652] |
Fri, 12 September 2008 05:16 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Hibernate walks through the associations therefore the call-stack is pretty long. I am surprised
that it works fine eventhough you get this exception.
gr. Martin
David Wynter wrote:
> Hi,
>
> Been using the annotation you showed below on my large model.
>
> I get this
>
> Exception in thread "main" java.lang.StackOverflowError
> at java.util.AbstractList$Itr.next(Unknown Source)
> at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3)
> at
> org.hibernate.mapping.PersistentClass.getProperty(Persistent Class.java:409)
> at
> org.hibernate.mapping.PersistentClass.getRecursiveProperty(P ersistentClass.java:391)
>
> at
> org.hibernate.mapping.PersistentClass.getReferencedProperty( PersistentClass.java:336)
>
> at
> org.hibernate.cfg.Configuration$1.getReferencedPropertyType( Configuration.java:2066)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:515)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
> at
> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>
>
> When I generate the schema now, but it does generate OK. But though you
> might be interested.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> The primarykeyjoincolumn should be placed in the following element:
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>
>> so something like this:
>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:instrumentDomain"
>> ecore:opposite="issueData">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @PrimaryKeyJoinColumn
>> </xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>
>> gr. Martin
>>
>> David Wynter wrote:
>>> Hi,
>>>
>>> The only example of the use of the PrimaryKeyJoinColumn is as follows
>>>
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @SecondaryTable(name="THETONER"
>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>>
>>> So to confirm its use in my case this would mean that IssueData would
>>> look like this?
>>>
>>> <xsd:complexType name="IssueData">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @SecondaryTable(name="InstrumentDomain"
>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>> </xsd:sequence>
>>> <xsd:attribute name="id" type="xsd:int">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">@Id
>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:attribute>
>>> </xsd:complexType>
>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>
>>> This works for the default TeneoSQLNameStrategy?
>>>
>>> Thx.
>>>
>>> David
>>>
>>>
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> You can force the location of the key field by setting the
>>>> PrimaryKeyJoinColumn annotation on the side where you want the fk
>>>> field to be.
>>>>
>>>> It this does not help can you post the generated hbm for the
>>>> reference elements from InstrumentDomain to IssueData and
>>>> DebtIssueData (and their opposite)?
>>>>
>>>> gr. Martin
>>>>
>>>> David Wynter wrote:
>>>>> Hi,
>>>>>
>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>> table in one case and the parent in the other case using the same
>>>>> annotations as here. I have stripped out the bulk of the references
>>>>> and attributes for clarity
>>>>>
>>>>> <xsd:complexType name="IssueData">
>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:attribute>
>>>>> </xsd:complexType>
>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>
>>>>> <xsd:complexType name="DebtIssueData">
>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:attribute>
>>>>> </xsd:complexType>
>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>
>>>>> <xsd:complexType name="InstrumentDomain">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentType" />
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:attribute>
>>>>> </xsd:complexType>
>>>>> <xsd:element name="instrumentDomain"
>>>>> type="gensec:InstrumentDomain" />
>>>>>
>>>>> what I end up with in the database is InstrumentDomain table with a
>>>>> FK called ISSUEDATA that points to IssueData table. And I get a FK
>>>>> in DebtIssueData table called INSTRUMENTDOMAIN that points to
>>>>> InstrumentDomain.
>>>>>
>>>>> So why is this inconsistent? What I really wanted is that for all
>>>>> InstrumentDomain references to other elements that have 0..1
>>>>> cardinality to have the FK in the optional table, in my example
>>>>> here IssueData and DebtIssueData would have FKs called
>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>> respectively.
>>>>>
>>>>> You may remember that I did have this
>>>>>
>>>>> <xsd:complexType name="InstrumentDomain">
>>>>> <xsd:sequence>
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentType" />
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:debtIssueData"
>>>>> ecore:opposite="instrumentDomain"/>
>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>> ecore:opposite="instrumentDomain"/>
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:attribute>
>>>>> </xsd:complexType>
>>>>> <xsd:element name="instrumentDomain"
>>>>> type="gensec:InstrumentDomain" />
>>>>>
>>>>> I expected that to put the FK into the IssueData and DebtIssueData
>>>>> respectively. But it does consistently (unlike the above case) put
>>>>> the FK column into InstrumentDomain table.
>>>>>
>>>>> Is there any way for me to achieve what I need? I need it because
>>>>> the data is loaded with a loader that expects the FK to be in the
>>>>> IssueData and DebtIssueData and any optional element that has a 1
>>>>> to 1 relationship with another element.
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [Teneo] Different generation using opposite [message #422669 is a reply to message #422657] |
Fri, 12 September 2008 11:50 |
Neil Brennan Messages: 14 Registered: July 2009 |
Junior Member |
|
|
Hi Martin,
I'm working with David, trying to do the Hibernate searches for the code
his model generates and the problem above is not just encountered on
generation. We can't actually store objects any more.
The stack trace on a JUnit test setup() looks like this:
java.lang.ExceptionInInitializerError
at com.stpware.secm.dwr.HibernateUtil.<clinit>
(HibernateUtil.java:78)
at com.stpware.secm.dwr.TestSearchEquity.setUp
(TestSearchEquity.java:40)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run
(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run
(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts
(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts
(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)
Caused by: java.lang.StackOverflowError
at java.util.Arrays.copyOf(Arrays.java:2760)
at java.util.ArrayList.toArray(ArrayList.java:305)
at org.hibernate.util.JoinedIterator.<init>(JoinedIterator.java:33)
at org.hibernate.mapping.PersistentClass.getPropertyIterator
(PersistentClass.java:541)
at org.hibernate.mapping.RootClass.getPropertyClosureIterator
(RootClass.java:87)
at
org.hibernate.mapping.PersistentClass.getReferenceableProper tyIterator
(PersistentClass.java:321)
at org.hibernate.mapping.PersistentClass.getReferencedProperty
(PersistentClass.java:336)
at org.hibernate.cfg.Configuration$1.getReferencedPropertyType
(Configuration.java:2066)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:515)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
...followed by thousands of the same line until DEATH.
I think David is going to send you the xsd directly as it is far too larg
to paste here!
Regards,
Neil
On Fri, 12 Sep 2008 07:16:09 +0200, Martin Taal wrote:
> Hi David,
> Hibernate walks through the associations therefore the call-stack is
> pretty long. I am surprised that it works fine eventhough you get this
> exception.
>
> gr. Martin
>
> David Wynter wrote:
>> Hi,
>>
>> Been using the annotation you showed below on my large model.
>>
>> I get this
>>
>> Exception in thread "main" java.lang.StackOverflowError
>> at java.util.AbstractList$Itr.next(Unknown Source) at
>> org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3) at
>> org.hibernate.mapping.PersistentClass.getProperty
(PersistentClass.java:409)
>> at
>> org.hibernate.mapping.PersistentClass.getRecursiveProperty
(PersistentClass.java:391)
>>
>> at
>> org.hibernate.mapping.PersistentClass.getReferencedProperty
(PersistentClass.java:336)
>>
>> at
>> org.hibernate.cfg.Configuration$1.getReferencedPropertyType
(Configuration.java:2066)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:515)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType
(EntityType.java:517)
>>
>>
>> When I generate the schema now, but it does generate OK. But though you
>> might be interested.
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> The primarykeyjoincolumn should be placed in the following element:
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>
>>> so something like this:
>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:instrumentDomain"
>>> ecore:opposite="issueData">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @PrimaryKeyJoinColumn
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:element>
>>>
>>> gr. Martin
>>>
>>> David Wynter wrote:
>>>> Hi,
>>>>
>>>> The only example of the use of the PrimaryKeyJoinColumn is as follows
>>>>
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @SecondaryTable(name="THETONER"
>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>>
>>>> So to confirm its use in my case this would mean that IssueData would
>>>> look like this?
>>>>
>>>> <xsd:complexType name="IssueData">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @SecondaryTable(name="InstrumentDomain"
>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:attribute>
>>>> </xsd:complexType>
>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>
>>>> This works for the default TeneoSQLNameStrategy?
>>>>
>>>> Thx.
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> You can force the location of the key field by setting the
>>>>> PrimaryKeyJoinColumn annotation on the side where you want the fk
>>>>> field to be.
>>>>>
>>>>> It this does not help can you post the generated hbm for the
>>>>> reference elements from InstrumentDomain to IssueData and
>>>>> DebtIssueData (and their opposite)?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> David Wynter wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>>> table in one case and the parent in the other case using the same
>>>>>> annotations as here. I have stripped out the bulk of the references
>>>>>> and attributes for clarity
>>>>>>
>>>>>> <xsd:complexType name="IssueData">
>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>
>>>>>> <xsd:complexType name="DebtIssueData">
>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>>
>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentType" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="instrumentDomain"
>>>>>> type="gensec:InstrumentDomain" />
>>>>>>
>>>>>> what I end up with in the database is InstrumentDomain table with a
>>>>>> FK called ISSUEDATA that points to IssueData table. And I get a FK
>>>>>> in DebtIssueData table called INSTRUMENTDOMAIN that points to
>>>>>> InstrumentDomain.
>>>>>>
>>>>>> So why is this inconsistent? What I really wanted is that for all
>>>>>> InstrumentDomain references to other elements that have 0..1
>>>>>> cardinality to have the FK in the optional table, in my example
>>>>>> here IssueData and DebtIssueData would have FKs called
>>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>>> respectively.
>>>>>>
>>>>>> You may remember that I did have this
>>>>>>
>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:debtIssueData"
>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="instrumentDomain"
>>>>>> type="gensec:InstrumentDomain" />
>>>>>>
>>>>>> I expected that to put the FK into the IssueData and DebtIssueData
>>>>>> respectively. But it does consistently (unlike the above case) put
>>>>>> the FK column into InstrumentDomain table.
>>>>>>
>>>>>> Is there any way for me to achieve what I need? I need it because
>>>>>> the data is loaded with a loader that expects the FK to be in the
>>>>>> IssueData and DebtIssueData and any optional element that has a 1
>>>>>> to 1 relationship with another element.
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
|
|
|
Re: [Teneo] Different generation using opposite [message #422681 is a reply to message #422657] |
Fri, 12 September 2008 15:42 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I finally narrowed this issue down. It is the addition of the
<xsd:element minOccurs="0" maxOccurs="1"
ref="gensec:instrumentDomain" ecore:opposite="issueData">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@PrimaryKeyJoinColumn
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
That appears to cause the exception. I checked out the version of my xsd
that was prior to adding these new annotations to control which end of a
0..1 relationship the FK was placed. Just the addition of a single one
of these annotations causes the StackOverflowException.
Thx.
David
Martin Taal wrote:
> Hi David,
> Hibernate walks through the associations therefore the call-stack is
> pretty long. I am surprised that it works fine eventhough you get this
> exception.
>
> gr. Martin
>
> David Wynter wrote:
>> Hi,
>>
>> Been using the annotation you showed below on my large model.
>>
>> I get this
>>
>> Exception in thread "main" java.lang.StackOverflowError
>> at java.util.AbstractList$Itr.next(Unknown Source)
>> at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3)
>> at
>> org.hibernate.mapping.PersistentClass.getProperty(Persistent Class.java:409)
>>
>> at
>> org.hibernate.mapping.PersistentClass.getRecursiveProperty(P ersistentClass.java:391)
>>
>> at
>> org.hibernate.mapping.PersistentClass.getReferencedProperty( PersistentClass.java:336)
>>
>> at
>> org.hibernate.cfg.Configuration$1.getReferencedPropertyType( Configuration.java:2066)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:515)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>> at
>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>
>>
>> When I generate the schema now, but it does generate OK. But though
>> you might be interested.
>>
>> David
>>
>> Martin Taal wrote:
>>> Hi David,
>>> The primarykeyjoincolumn should be placed in the following element:
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>
>>> so something like this:
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @PrimaryKeyJoinColumn
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:element>
>>>
>>> gr. Martin
>>>
>>> David Wynter wrote:
>>>> Hi,
>>>>
>>>> The only example of the use of the PrimaryKeyJoinColumn is as follows
>>>>
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @SecondaryTable(name="THETONER"
>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>>
>>>> So to confirm its use in my case this would mean that IssueData
>>>> would look like this?
>>>>
>>>> <xsd:complexType name="IssueData">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @SecondaryTable(name="InstrumentDomain"
>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>> </xsd:sequence>
>>>> <xsd:attribute name="id" type="xsd:int">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:attribute>
>>>> </xsd:complexType>
>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>
>>>> This works for the default TeneoSQLNameStrategy?
>>>>
>>>> Thx.
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> You can force the location of the key field by setting the
>>>>> PrimaryKeyJoinColumn annotation on the side where you want the fk
>>>>> field to be.
>>>>>
>>>>> It this does not help can you post the generated hbm for the
>>>>> reference elements from InstrumentDomain to IssueData and
>>>>> DebtIssueData (and their opposite)?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> David Wynter wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>>> table in one case and the parent in the other case using the same
>>>>>> annotations as here. I have stripped out the bulk of the
>>>>>> references and attributes for clarity
>>>>>>
>>>>>> <xsd:complexType name="IssueData">
>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>
>>>>>> <xsd:complexType name="DebtIssueData">
>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>>
>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentType" />
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="instrumentDomain"
>>>>>> type="gensec:InstrumentDomain" />
>>>>>>
>>>>>> what I end up with in the database is InstrumentDomain table with
>>>>>> a FK called ISSUEDATA that points to IssueData table. And I get a
>>>>>> FK in DebtIssueData table called INSTRUMENTDOMAIN that points to
>>>>>> InstrumentDomain.
>>>>>>
>>>>>> So why is this inconsistent? What I really wanted is that for all
>>>>>> InstrumentDomain references to other elements that have 0..1
>>>>>> cardinality to have the FK in the optional table, in my example
>>>>>> here IssueData and DebtIssueData would have FKs called
>>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>>> respectively.
>>>>>>
>>>>>> You may remember that I did have this
>>>>>>
>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>> <xsd:sequence>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentType" />
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:debtIssueData" ecore:opposite="instrumentDomain"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="instrumentDomain"
>>>>>> type="gensec:InstrumentDomain" />
>>>>>>
>>>>>> I expected that to put the FK into the IssueData and DebtIssueData
>>>>>> respectively. But it does consistently (unlike the above case) put
>>>>>> the FK column into InstrumentDomain table.
>>>>>>
>>>>>> Is there any way for me to achieve what I need? I need it because
>>>>>> the data is loaded with a loader that expects the FK to be in the
>>>>>> IssueData and DebtIssueData and any optional element that has a 1
>>>>>> to 1 relationship with another element.
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Different generation using opposite [message #422718 is a reply to message #422681] |
Sun, 14 September 2008 22:24 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I had a close look at the generated hibernate.hbm.xml and it is
generated with identical treatments for debtIssueData and issueData.
Which suggests that the in memory model that Teneo generates and uses is
different to that that would be generated by the hibernate.hbm.xml.
Unfortunately when I tried to get it to use that hibernate.hbm.xml using
both the PersistanceOptions.MAPPING_FILE_PATH with either relative or
full pathnames it got a HbStoreException and could not find the file. I
also tried the USE_MAPPING_FILE = true and it ran at least but produced
no schema.
I am on Windows XP using 1.0.1 Teneo.
David
David Wynter wrote:
> Hi,
>
> I finally narrowed this issue down. It is the addition of the
>
> <xsd:element minOccurs="0" maxOccurs="1"
> ref="gensec:instrumentDomain" ecore:opposite="issueData">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">
> @PrimaryKeyJoinColumn
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> That appears to cause the exception. I checked out the version of my xsd
> that was prior to adding these new annotations to control which end of a
> 0..1 relationship the FK was placed. Just the addition of a single one
> of these annotations causes the StackOverflowException.
>
> Thx.
>
> David
>
>
>
> Martin Taal wrote:
>> Hi David,
>> Hibernate walks through the associations therefore the call-stack is
>> pretty long. I am surprised that it works fine eventhough you get this
>> exception.
>>
>> gr. Martin
>>
>> David Wynter wrote:
>>> Hi,
>>>
>>> Been using the annotation you showed below on my large model.
>>>
>>> I get this
>>>
>>> Exception in thread "main" java.lang.StackOverflowError
>>> at java.util.AbstractList$Itr.next(Unknown Source)
>>> at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3)
>>> at
>>> org.hibernate.mapping.PersistentClass.getProperty(Persistent Class.java:409)
>>>
>>> at
>>> org.hibernate.mapping.PersistentClass.getRecursiveProperty(P ersistentClass.java:391)
>>>
>>> at
>>> org.hibernate.mapping.PersistentClass.getReferencedProperty( PersistentClass.java:336)
>>>
>>> at
>>> org.hibernate.cfg.Configuration$1.getReferencedPropertyType( Configuration.java:2066)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:515)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>> at
>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>
>>>
>>> When I generate the schema now, but it does generate OK. But though
>>> you might be interested.
>>>
>>> David
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> The primarykeyjoincolumn should be placed in the following element:
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>
>>>> so something like this:
>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>>>> <xsd:annotation>
>>>> <xsd:appinfo source="teneo.jpa">
>>>> @PrimaryKeyJoinColumn
>>>> </xsd:appinfo>
>>>> </xsd:annotation>
>>>> </xsd:element>
>>>>
>>>> gr. Martin
>>>>
>>>> David Wynter wrote:
>>>>> Hi,
>>>>>
>>>>> The only example of the use of the PrimaryKeyJoinColumn is as follows
>>>>>
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @SecondaryTable(name="THETONER"
>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>>
>>>>> So to confirm its use in my case this would mean that IssueData
>>>>> would look like this?
>>>>>
>>>>> <xsd:complexType name="IssueData">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @SecondaryTable(name="InstrumentDomain"
>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>> </xsd:sequence>
>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:attribute>
>>>>> </xsd:complexType>
>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>
>>>>> This works for the default TeneoSQLNameStrategy?
>>>>>
>>>>> Thx.
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> You can force the location of the key field by setting the
>>>>>> PrimaryKeyJoinColumn annotation on the side where you want the fk
>>>>>> field to be.
>>>>>>
>>>>>> It this does not help can you post the generated hbm for the
>>>>>> reference elements from InstrumentDomain to IssueData and
>>>>>> DebtIssueData (and their opposite)?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> David Wynter wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>>>> table in one case and the parent in the other case using the same
>>>>>>> annotations as here. I have stripped out the bulk of the
>>>>>>> references and attributes for clarity
>>>>>>>
>>>>>>> <xsd:complexType name="IssueData">
>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> </xsd:attribute>
>>>>>>> </xsd:complexType>
>>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>>
>>>>>>> <xsd:complexType name="DebtIssueData">
>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> </xsd:attribute>
>>>>>>> </xsd:complexType>
>>>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>>>
>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentType" />
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>> </xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> </xsd:attribute>
>>>>>>> </xsd:complexType>
>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>
>>>>>>> what I end up with in the database is InstrumentDomain table with
>>>>>>> a FK called ISSUEDATA that points to IssueData table. And I get a
>>>>>>> FK in DebtIssueData table called INSTRUMENTDOMAIN that points to
>>>>>>> InstrumentDomain.
>>>>>>>
>>>>>>> So why is this inconsistent? What I really wanted is that for all
>>>>>>> InstrumentDomain references to other elements that have 0..1
>>>>>>> cardinality to have the FK in the optional table, in my example
>>>>>>> here IssueData and DebtIssueData would have FKs called
>>>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>>>> respectively.
>>>>>>>
>>>>>>> You may remember that I did have this
>>>>>>>
>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>> <xsd:sequence>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentType" />
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:debtIssueData" ecore:opposite="instrumentDomain"/>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>> </xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> </xsd:attribute>
>>>>>>> </xsd:complexType>
>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>
>>>>>>> I expected that to put the FK into the IssueData and
>>>>>>> DebtIssueData respectively. But it does consistently (unlike the
>>>>>>> above case) put the FK column into InstrumentDomain table.
>>>>>>>
>>>>>>> Is there any way for me to achieve what I need? I need it because
>>>>>>> the data is loaded with a loader that expects the FK to be in the
>>>>>>> IssueData and DebtIssueData and any optional element that has a 1
>>>>>>> to 1 relationship with another element.
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: [Teneo] Different generation for 0..2 [message #422723 is a reply to message #422718] |
Mon, 15 September 2008 11:01 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I cannot find a way forward with this problem.
In the end I decided to try to force the FK in the entities related 0..1
to instrumentDomain by adding these
<xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
maxOccurs="2" ref="gensec:lastCAE" />
<xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
maxOccurs="2" ref="gensec:debtIssueData" />
<xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
maxOccurs="2" ref="gensec:issueData" />
i.e. forcing the FK in a 0..2 relationship. The hibernate.hbm.xml
generated does not make sense. Here are the 3 0..2 I show above as
inside the
<class name="com.stpenable.gensec.impl.InstrumentDomainImpl"
entity-name="InstrumentDomain" abstract="false" lazy="false"
table="`instrumentdomain`">
<one-to-one name="lastCAE" entity-name="LastCAE"
foreign-key="instrumentdomain_lastcae" cascade="all" lazy="false"
property-ref="instrumentDomain"/>
the other 2 do not appear!!!!!!
They appear as
<one-to-one name="instrumentDomain" entity-name="InstrumentDomain"
foreign-key="issuedata_instrumentdomain" cascade="all" lazy="false"
constrained="true"/>
inside the
<class name="com.stpenable.gensec.impl.IssueDataImpl"
entity-name="IssueData" abstract="false" lazy="false" table="`issuedata`">
and as
<one-to-one name="instrumentDomain" entity-name="InstrumentDomain"
foreign-key="debtissuedata_instrumentdomain" cascade="all" lazy="false"
property-ref="debtIssueData"/>
inside the
<class name="com.stpenable.gensec.impl.DebtIssueDataImpl"
entity-name="DebtIssueData" abstract="false" lazy="false"
table="`debtissuedata`">
How can it treat the same annotation (0..2) completely differently?? Is
this a bug?
David
David Wynter wrote:
> Hi,
>
> I had a close look at the generated hibernate.hbm.xml and it is
> generated with identical treatments for debtIssueData and issueData.
> Which suggests that the in memory model that Teneo generates and uses is
> different to that that would be generated by the hibernate.hbm.xml.
>
> Unfortunately when I tried to get it to use that hibernate.hbm.xml using
> both the PersistanceOptions.MAPPING_FILE_PATH with either relative or
> full pathnames it got a HbStoreException and could not find the file. I
> also tried the USE_MAPPING_FILE = true and it ran at least but produced
> no schema.
>
> I am on Windows XP using 1.0.1 Teneo.
>
> David
>
> David Wynter wrote:
>> Hi,
>>
>> I finally narrowed this issue down. It is the addition of the
>>
>> <xsd:element minOccurs="0" maxOccurs="1"
>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">
>> @PrimaryKeyJoinColumn
>> </xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>
>> That appears to cause the exception. I checked out the version of my
>> xsd that was prior to adding these new annotations to control which
>> end of a 0..1 relationship the FK was placed. Just the addition of a
>> single one of these annotations causes the StackOverflowException.
>>
>> Thx.
>>
>> David
>>
>>
>>
>> Martin Taal wrote:
>>> Hi David,
>>> Hibernate walks through the associations therefore the call-stack is
>>> pretty long. I am surprised that it works fine eventhough you get
>>> this exception.
>>>
>>> gr. Martin
>>>
>>> David Wynter wrote:
>>>> Hi,
>>>>
>>>> Been using the annotation you showed below on my large model.
>>>>
>>>> I get this
>>>>
>>>> Exception in thread "main" java.lang.StackOverflowError
>>>> at java.util.AbstractList$Itr.next(Unknown Source)
>>>> at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3)
>>>> at
>>>> org.hibernate.mapping.PersistentClass.getProperty(Persistent Class.java:409)
>>>>
>>>> at
>>>> org.hibernate.mapping.PersistentClass.getRecursiveProperty(P ersistentClass.java:391)
>>>>
>>>> at
>>>> org.hibernate.mapping.PersistentClass.getReferencedProperty( PersistentClass.java:336)
>>>>
>>>> at
>>>> org.hibernate.cfg.Configuration$1.getReferencedPropertyType( Configuration.java:2066)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:515)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>> at
>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>
>>>>
>>>> When I generate the schema now, but it does generate OK. But though
>>>> you might be interested.
>>>>
>>>> David
>>>>
>>>> Martin Taal wrote:
>>>>> Hi David,
>>>>> The primarykeyjoincolumn should be placed in the following element:
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>
>>>>> so something like this:
>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>>>>> <xsd:annotation>
>>>>> <xsd:appinfo source="teneo.jpa">
>>>>> @PrimaryKeyJoinColumn
>>>>> </xsd:appinfo>
>>>>> </xsd:annotation>
>>>>> </xsd:element>
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> David Wynter wrote:
>>>>>> Hi,
>>>>>>
>>>>>> The only example of the use of the PrimaryKeyJoinColumn is as follows
>>>>>>
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @SecondaryTable(name="THETONER"
>>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>>
>>>>>> So to confirm its use in my case this would mean that IssueData
>>>>>> would look like this?
>>>>>>
>>>>>> <xsd:complexType name="IssueData">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @SecondaryTable(name="InstrumentDomain"
>>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>> </xsd:sequence>
>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:attribute>
>>>>>> </xsd:complexType>
>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>
>>>>>> This works for the default TeneoSQLNameStrategy?
>>>>>>
>>>>>> Thx.
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi David,
>>>>>>> You can force the location of the key field by setting the
>>>>>>> PrimaryKeyJoinColumn annotation on the side where you want the fk
>>>>>>> field to be.
>>>>>>>
>>>>>>> It this does not help can you post the generated hbm for the
>>>>>>> reference elements from InstrumentDomain to IssueData and
>>>>>>> DebtIssueData (and their opposite)?
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> David Wynter wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>>>>> table in one case and the parent in the other case using the
>>>>>>>> same annotations as here. I have stripped out the bulk of the
>>>>>>>> references and attributes for clarity
>>>>>>>>
>>>>>>>> <xsd:complexType name="IssueData">
>>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>> <xsd:annotation>
>>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>>> </xsd:annotation>
>>>>>>>> </xsd:attribute>
>>>>>>>> </xsd:complexType>
>>>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>>>
>>>>>>>> <xsd:complexType name="DebtIssueData">
>>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>> <xsd:annotation>
>>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>>> </xsd:annotation>
>>>>>>>> </xsd:attribute>
>>>>>>>> </xsd:complexType>
>>>>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>>>>
>>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentType" />
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>> <xsd:annotation>
>>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>>> </xsd:appinfo>
>>>>>>>> </xsd:annotation>
>>>>>>>> </xsd:attribute>
>>>>>>>> </xsd:complexType>
>>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>>
>>>>>>>> what I end up with in the database is InstrumentDomain table
>>>>>>>> with a FK called ISSUEDATA that points to IssueData table. And I
>>>>>>>> get a FK in DebtIssueData table called INSTRUMENTDOMAIN that
>>>>>>>> points to InstrumentDomain.
>>>>>>>>
>>>>>>>> So why is this inconsistent? What I really wanted is that for
>>>>>>>> all InstrumentDomain references to other elements that have 0..1
>>>>>>>> cardinality to have the FK in the optional table, in my example
>>>>>>>> here IssueData and DebtIssueData would have FKs called
>>>>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>>>>> respectively.
>>>>>>>>
>>>>>>>> You may remember that I did have this
>>>>>>>>
>>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>>> <xsd:sequence>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:instrumentType" />
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>> ref="gensec:debtIssueData" ecore:opposite="instrumentDomain"/>
>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>>>> </xsd:sequence>
>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>> <xsd:annotation>
>>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>>> </xsd:appinfo>
>>>>>>>> </xsd:annotation>
>>>>>>>> </xsd:attribute>
>>>>>>>> </xsd:complexType>
>>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>>
>>>>>>>> I expected that to put the FK into the IssueData and
>>>>>>>> DebtIssueData respectively. But it does consistently (unlike the
>>>>>>>> above case) put the FK column into InstrumentDomain table.
>>>>>>>>
>>>>>>>> Is there any way for me to achieve what I need? I need it
>>>>>>>> because the data is loaded with a loader that expects the FK to
>>>>>>>> be in the IssueData and DebtIssueData and any optional element
>>>>>>>> that has a 1 to 1 relationship with another element.
>>>>>>>>
>>>>>>>> David
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
|
|
|
Re: [Teneo] Different generation for 0..2 [message #422724 is a reply to message #422723] |
Mon, 15 September 2008 11:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
What do you see generated on the java side? I would expect that the maxOccurs="2" will generate a
list in java. This should then generate a one-to-many in hibernate.
Btw, would it be possible for me to send me your complete model (by email)? This would help me to
look in more detail at the issues you encounter.
gr. Martin
David Wynter wrote:
> Hi,
>
> I cannot find a way forward with this problem.
>
> In the end I decided to try to force the FK in the entities related 0..1
> to instrumentDomain by adding these
>
> <xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
> maxOccurs="2" ref="gensec:lastCAE" />
> <xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
> maxOccurs="2" ref="gensec:debtIssueData" />
> <xsd:element ecore:opposite="instrumentDomain" minOccurs="0"
> maxOccurs="2" ref="gensec:issueData" />
>
> i.e. forcing the FK in a 0..2 relationship. The hibernate.hbm.xml
> generated does not make sense. Here are the 3 0..2 I show above as
> inside the
> <class name="com.stpenable.gensec.impl.InstrumentDomainImpl"
> entity-name="InstrumentDomain" abstract="false" lazy="false"
> table="`instrumentdomain`">
>
> <one-to-one name="lastCAE" entity-name="LastCAE"
> foreign-key="instrumentdomain_lastcae" cascade="all" lazy="false"
> property-ref="instrumentDomain"/>
>
> the other 2 do not appear!!!!!!
>
> They appear as
>
> <one-to-one name="instrumentDomain"
> entity-name="InstrumentDomain" foreign-key="issuedata_instrumentdomain"
> cascade="all" lazy="false" constrained="true"/>
>
> inside the
> <class name="com.stpenable.gensec.impl.IssueDataImpl"
> entity-name="IssueData" abstract="false" lazy="false" table="`issuedata`">
>
> and as
>
> <one-to-one name="instrumentDomain"
> entity-name="InstrumentDomain"
> foreign-key="debtissuedata_instrumentdomain" cascade="all" lazy="false"
> property-ref="debtIssueData"/>
>
> inside the
>
> <class name="com.stpenable.gensec.impl.DebtIssueDataImpl"
> entity-name="DebtIssueData" abstract="false" lazy="false"
> table="`debtissuedata`">
>
>
> How can it treat the same annotation (0..2) completely differently?? Is
> this a bug?
>
> David
>
>
>
> David Wynter wrote:
>> Hi,
>>
>> I had a close look at the generated hibernate.hbm.xml and it is
>> generated with identical treatments for debtIssueData and issueData.
>> Which suggests that the in memory model that Teneo generates and uses
>> is different to that that would be generated by the hibernate.hbm.xml.
>>
>> Unfortunately when I tried to get it to use that hibernate.hbm.xml
>> using both the PersistanceOptions.MAPPING_FILE_PATH with either
>> relative or full pathnames it got a HbStoreException and could not
>> find the file. I also tried the USE_MAPPING_FILE = true and it ran at
>> least but produced no schema.
>>
>> I am on Windows XP using 1.0.1 Teneo.
>>
>> David
>>
>> David Wynter wrote:
>>> Hi,
>>>
>>> I finally narrowed this issue down. It is the addition of the
>>>
>>> <xsd:element minOccurs="0" maxOccurs="1"
>>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>>> <xsd:annotation>
>>> <xsd:appinfo source="teneo.jpa">
>>> @PrimaryKeyJoinColumn
>>> </xsd:appinfo>
>>> </xsd:annotation>
>>> </xsd:element>
>>>
>>> That appears to cause the exception. I checked out the version of my
>>> xsd that was prior to adding these new annotations to control which
>>> end of a 0..1 relationship the FK was placed. Just the addition of a
>>> single one of these annotations causes the StackOverflowException.
>>>
>>> Thx.
>>>
>>> David
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi David,
>>>> Hibernate walks through the associations therefore the call-stack is
>>>> pretty long. I am surprised that it works fine eventhough you get
>>>> this exception.
>>>>
>>>> gr. Martin
>>>>
>>>> David Wynter wrote:
>>>>> Hi,
>>>>>
>>>>> Been using the annotation you showed below on my large model.
>>>>>
>>>>> I get this
>>>>>
>>>>> Exception in thread "main" java.lang.StackOverflowError
>>>>> at java.util.AbstractList$Itr.next(Unknown Source)
>>>>> at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:5 3)
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.getProperty(Persistent Class.java:409)
>>>>>
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.getRecursiveProperty(P ersistentClass.java:391)
>>>>>
>>>>> at
>>>>> org.hibernate.mapping.PersistentClass.getReferencedProperty( PersistentClass.java:336)
>>>>>
>>>>> at
>>>>> org.hibernate.cfg.Configuration$1.getReferencedPropertyType( Configuration.java:2066)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:515)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>> at
>>>>> org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(E ntityType.java:517)
>>>>>
>>>>>
>>>>> When I generate the schema now, but it does generate OK. But though
>>>>> you might be interested.
>>>>>
>>>>> David
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi David,
>>>>>> The primarykeyjoincolumn should be placed in the following element:
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>>
>>>>>> so something like this:
>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData">
>>>>>> <xsd:annotation>
>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>> @PrimaryKeyJoinColumn
>>>>>> </xsd:appinfo>
>>>>>> </xsd:annotation>
>>>>>> </xsd:element>
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> David Wynter wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> The only example of the use of the PrimaryKeyJoinColumn is as
>>>>>>> follows
>>>>>>>
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>> @SecondaryTable(name="THETONER"
>>>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="PRINTER_ID")})
>>>>>>> </xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>>
>>>>>>> So to confirm its use in my case this would mean that IssueData
>>>>>>> would look like this?
>>>>>>>
>>>>>>> <xsd:complexType name="IssueData">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>> @SecondaryTable(name="InstrumentDomain"
>>>>>>> pkJoinColumns={@PrimaryKeyJoinColumn(name="id")})
>>>>>>> </xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>> </xsd:sequence>
>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>> <xsd:annotation>
>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>> </xsd:annotation>
>>>>>>> </xsd:attribute>
>>>>>>> </xsd:complexType>
>>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>>
>>>>>>> This works for the default TeneoSQLNameStrategy?
>>>>>>>
>>>>>>> Thx.
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Martin Taal wrote:
>>>>>>>> Hi David,
>>>>>>>> You can force the location of the key field by setting the
>>>>>>>> PrimaryKeyJoinColumn annotation on the side where you want the
>>>>>>>> fk field to be.
>>>>>>>>
>>>>>>>> It this does not help can you post the generated hbm for the
>>>>>>>> reference elements from InstrumentDomain to IssueData and
>>>>>>>> DebtIssueData (and their opposite)?
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> David Wynter wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I am getting the FK for a 0..1 cardinality set in the optional
>>>>>>>>> table in one case and the parent in the other case using the
>>>>>>>>> same annotations as here. I have stripped out the bulk of the
>>>>>>>>> references and attributes for clarity
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="IssueData">
>>>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="issueData"/>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>>> <xsd:annotation>
>>>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>>>> </xsd:annotation>
>>>>>>>>> </xsd:attribute>
>>>>>>>>> </xsd:complexType>
>>>>>>>>> <xsd:element name="issueData" type="gensec:IssueData" />
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="DebtIssueData">
>>>>>>>>> <xsd:sequence minOccurs="0" maxOccurs="1">
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentDomain" ecore:opposite="debtIssueData"/>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="unbounded"
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>>> <xsd:annotation>
>>>>>>>>> <xsd:appinfo source="teneo.jpa">@Id
>>>>>>>>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>>>>>>>>> </xsd:annotation>
>>>>>>>>> </xsd:attribute>
>>>>>>>>> </xsd:complexType>
>>>>>>>>> <xsd:element name="debtIssueData" type="gensec:DebtIssueData" />
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>>>> <xsd:sequence>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentType" />
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>>> <xsd:annotation>
>>>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>>>> </xsd:appinfo>
>>>>>>>>> </xsd:annotation>
>>>>>>>>> </xsd:attribute>
>>>>>>>>> </xsd:complexType>
>>>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>>>
>>>>>>>>> what I end up with in the database is InstrumentDomain table
>>>>>>>>> with a FK called ISSUEDATA that points to IssueData table. And
>>>>>>>>> I get a FK in DebtIssueData table called INSTRUMENTDOMAIN that
>>>>>>>>> points to InstrumentDomain.
>>>>>>>>>
>>>>>>>>> So why is this inconsistent? What I really wanted is that for
>>>>>>>>> all InstrumentDomain references to other elements that have
>>>>>>>>> 0..1 cardinality to have the FK in the optional table, in my
>>>>>>>>> example here IssueData and DebtIssueData would have FKs called
>>>>>>>>> issuedata_instrumentdomain and debtissuedata_instrumentdomain
>>>>>>>>> respectively.
>>>>>>>>>
>>>>>>>>> You may remember that I did have this
>>>>>>>>>
>>>>>>>>> <xsd:complexType name="InstrumentDomain">
>>>>>>>>> <xsd:sequence>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:instrumentType" />
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1"
>>>>>>>>> ref="gensec:debtIssueData" ecore:opposite="instrumentDomain"/>
>>>>>>>>> <xsd:element minOccurs="0" maxOccurs="1" ref="gensec:issueData"
>>>>>>>>> ecore:opposite="instrumentDomain"/>
>>>>>>>>> </xsd:sequence>
>>>>>>>>> <xsd:attribute name="id" type="xsd:int">
>>>>>>>>> <xsd:annotation>
>>>>>>>>> <xsd:appinfo source="teneo.jpa">
>>>>>>>>> @Id @GeneratedValue(strategy=IDENTITY)
>>>>>>>>> </xsd:appinfo>
>>>>>>>>> </xsd:annotation>
>>>>>>>>> </xsd:attribute>
>>>>>>>>> </xsd:complexType>
>>>>>>>>> <xsd:element name="instrumentDomain"
>>>>>>>>> type="gensec:InstrumentDomain" />
>>>>>>>>>
>>>>>>>>> I expected that to put the FK into the IssueData and
>>>>>>>>> DebtIssueData respectively. But it does consistently (unlike
>>>>>>>>> the above case) put the FK column into InstrumentDomain table.
>>>>>>>>>
>>>>>>>>> Is there any way for me to achieve what I need? I need it
>>>>>>>>> because the data is loaded with a loader that expects the FK to
>>>>>>>>> be in the IssueData and DebtIssueData and any optional element
>>>>>>>>> that has a 1 to 1 relationship with another element.
>>>>>>>>>
>>>>>>>>> David
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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
|
|
|
Goto Forum:
Current Time: Mon Sep 23 00:07:30 GMT 2024
Powered by FUDForum. Page generated in 0.05281 seconds
|