Home » Modeling » EMF » [Teneo] @ManyToMany JPA Annotation give double association table
| | |
Re: [Teneo] @ManyToMany JPA Annotation give double association table [message #426184 is a reply to message #426183] |
Thu, 18 December 2008 13:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
Normally Teneo should detect the mtm and create one jointable if both sides are non-indexed. What
are the tablenames?
There are no other annotations on the two ereferences?
You can set a @JoinTable(name="myJoinTable") on both sides with the same join table name. Then both
sides should use the same jointable.
gr. Martin
Thomas wrote:
> Response in your message
>
> Martin Taal a écrit :
>> Hi Thomas,
>> Indexed mtm relations with one join table are not supported by hibernate:
>> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+indexed+many-to-many+(nm)+relations
>>
>> a solution is to make both sides non-indexed by setting indexed=false
>> on the association. But then you can't predict the order in which the
>> elements are returned.
> Oh yes, I have forgotten this specific teneo property.
> But ever with that property, I have 2 tables, without indexes now. Is
> the action of changing the name of a table (as resource is a key word
> for oracle we use OResource instead) can make this behavior?
>
>>
>> I am not sure why the repeated column exception occurs... Did you set
>> the @JoinTable annotation on both sides?
> No, it was on one side.
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Hello (Martin ? ;),
>>>
>>> A strange stuff with teneo and ManyToMany bidirectionnal relations
>>>
>>> I have a bidirectionnal ManyToMany between Resource (table ORESOURCE)
>>> and ResourceCategory
>>> I put on the ManyToMany of Resource a mappedBy as I want the
>>> ResourceCategory would be the master.
>>> On the generated database, I have 2 tables of relation
>>> one call ORSRC_RESRCECTEGRY with a composite id on the id of
>>> ORESOURCE and an index
>>> one other call RSRCECTEGRY_RESRCE with a composite id on the id of
>>> ResourceCategory and an index
>>> It works with those both association, but why is there not only one
>>> relation table with a composite id on id of OResource and the id of
>>> Resource Category ???
>>>
>>>
>>> And if I try to force the JoinTable to be on both ID with this
>>> annotation
>>> @JoinTable(
>>> joinColumns=@JoinColumn(referencedColumnName=ID)
>>> inverseJoinColumns=@JoinColumn(referencedColumnName=ID)
>>> )
>>> I have this error:
>>> Repeated column in mapping for collection: ResourceCategory.resources
>>> column: NULL
>>>
>>> Thanks for the light you can give to me
>>>
>>> Thomas
>>
>>
--
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] @ManyToMany JPA Annotation give double association table [message #426190 is a reply to message #426184] |
Thu, 18 December 2008 16:20 |
Thomas Messages: 37 Registered: July 2009 |
Member |
|
|
Ok, I have add a @JoinTable(name="RSRCECTEGRY_RESRCE") on both side
the result is a table RSRCECTEGRY_RESRCE with 4 columns columns, 2 with
Resource id and 2 with ResourceCategory id
I know that we can also force column name, BUT
I have also a table called ORSRC_RESRCECTEGRY. Can it be teneo that add
this relation in my back ???
Martin Taal a écrit :
> Hi Thomas,
> Normally Teneo should detect the mtm and create one jointable if both
> sides are non-indexed. What are the tablenames?
>
> There are no other annotations on the two ereferences?
>
> You can set a @JoinTable(name="myJoinTable") on both sides with the same
> join table name. Then both sides should use the same jointable.
>
> gr. Martin
>
> Thomas wrote:
>> Response in your message
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> Indexed mtm relations with one join table are not supported by
>>> hibernate:
>>> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+indexed+many-to-many+(nm)+relations
>>>
>>> a solution is to make both sides non-indexed by setting indexed=false
>>> on the association. But then you can't predict the order in which the
>>> elements are returned.
>> Oh yes, I have forgotten this specific teneo property.
>> But ever with that property, I have 2 tables, without indexes now. Is
>> the action of changing the name of a table (as resource is a key word
>> for oracle we use OResource instead) can make this behavior?
>>
>>>
>>> I am not sure why the repeated column exception occurs... Did you set
>>> the @JoinTable annotation on both sides?
>> No, it was on one side.
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> Hello (Martin ? ;),
>>>>
>>>> A strange stuff with teneo and ManyToMany bidirectionnal relations
>>>>
>>>> I have a bidirectionnal ManyToMany between Resource (table
>>>> ORESOURCE) and ResourceCategory
>>>> I put on the ManyToMany of Resource a mappedBy as I want the
>>>> ResourceCategory would be the master.
>>>> On the generated database, I have 2 tables of relation
>>>> one call ORSRC_RESRCECTEGRY with a composite id on the id of
>>>> ORESOURCE and an index
>>>> one other call RSRCECTEGRY_RESRCE with a composite id on the id of
>>>> ResourceCategory and an index
>>>> It works with those both association, but why is there not only one
>>>> relation table with a composite id on id of OResource and the id of
>>>> Resource Category ???
>>>>
>>>>
>>>> And if I try to force the JoinTable to be on both ID with this
>>>> annotation
>>>> @JoinTable(
>>>> joinColumns=@JoinColumn(referencedColumnName=ID)
>>>> inverseJoinColumns=@JoinColumn(referencedColumnName=ID)
>>>> )
>>>> I have this error:
>>>> Repeated column in mapping for collection:
>>>> ResourceCategory.resources column: NULL
>>>>
>>>> Thanks for the light you can give to me
>>>>
>>>> Thomas
>>>
>>>
>
>
|
|
|
Re: [Teneo] @ManyToMany JPA Annotation give double association table [message #426191 is a reply to message #426190] |
Thu, 18 December 2008 16:35 |
Thomas Messages: 37 Registered: July 2009 |
Member |
|
|
Here is the getMappingXML():
<class entity-name="Oresource" abstract="false" lazy="false"
discriminator-value="Oresource" table="`ORESOURCE`">
<bag name="resourceCategories" lazy="true" cascade="refresh"
inverse="true" table="`ORSRC_RESRCECTEGRY`">
<key/>
<many-to-many entity-name="ResourceCategory" unique="false"
foreign-key="ORSRC_RSRCCTEGRIES"/>
</bag>
<class entity-name="ResourceCategory" abstract="false" lazy="false"
discriminator-value="ResourceCategory" table="`RESOURCECATEGORY`">
<bag name="resources" lazy="false" cascade="all"
table="`RSRCECTEGRY_RESRCE`">
<key/>
<many-to-many entity-name="Oresource" unique="false"
foreign-key="RSRCCTEGRY_RESRCES"/>
</bag>
Thomas a écrit :
> Ok, I have add a @JoinTable(name="RSRCECTEGRY_RESRCE") on both side
> the result is a table RSRCECTEGRY_RESRCE with 4 columns columns, 2 with
> Resource id and 2 with ResourceCategory id
> I know that we can also force column name, BUT
> I have also a table called ORSRC_RESRCECTEGRY. Can it be teneo that add
> this relation in my back ???
>
> Martin Taal a écrit :
>> Hi Thomas,
>> Normally Teneo should detect the mtm and create one jointable if both
>> sides are non-indexed. What are the tablenames?
>>
>> There are no other annotations on the two ereferences?
>>
>> You can set a @JoinTable(name="myJoinTable") on both sides with the
>> same join table name. Then both sides should use the same jointable.
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Response in your message
>>>
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> Indexed mtm relations with one join table are not supported by
>>>> hibernate:
>>>> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+indexed+many-to-many+(nm)+relations
>>>>
>>>> a solution is to make both sides non-indexed by setting
>>>> indexed=false on the association. But then you can't predict the
>>>> order in which the elements are returned.
>>> Oh yes, I have forgotten this specific teneo property.
>>> But ever with that property, I have 2 tables, without indexes now. Is
>>> the action of changing the name of a table (as resource is a key word
>>> for oracle we use OResource instead) can make this behavior?
>>>
>>>>
>>>> I am not sure why the repeated column exception occurs... Did you
>>>> set the @JoinTable annotation on both sides?
>>> No, it was on one side.
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas wrote:
>>>>> Hello (Martin ? ;),
>>>>>
>>>>> A strange stuff with teneo and ManyToMany bidirectionnal relations
>>>>>
>>>>> I have a bidirectionnal ManyToMany between Resource (table
>>>>> ORESOURCE) and ResourceCategory
>>>>> I put on the ManyToMany of Resource a mappedBy as I want the
>>>>> ResourceCategory would be the master.
>>>>> On the generated database, I have 2 tables of relation
>>>>> one call ORSRC_RESRCECTEGRY with a composite id on the id of
>>>>> ORESOURCE and an index
>>>>> one other call RSRCECTEGRY_RESRCE with a composite id on the id of
>>>>> ResourceCategory and an index
>>>>> It works with those both association, but why is there not only one
>>>>> relation table with a composite id on id of OResource and the id of
>>>>> Resource Category ???
>>>>>
>>>>>
>>>>> And if I try to force the JoinTable to be on both ID with this
>>>>> annotation
>>>>> @JoinTable(
>>>>> joinColumns=@JoinColumn(referencedColumnName=ID)
>>>>> inverseJoinColumns=@JoinColumn(referencedColumnName=ID)
>>>>> )
>>>>> I have this error:
>>>>> Repeated column in mapping for collection:
>>>>> ResourceCategory.resources column: NULL
>>>>>
>>>>> Thanks for the light you can give to me
>>>>>
>>>>> Thomas
>>>>
>>>>
>>
>>
|
|
|
Re: [Teneo] @ManyToMany JPA Annotation give double association table [message #426192 is a reply to message #426191] |
Thu, 18 December 2008 16:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
Seems indeed strange, the mapping shows two join tables although you added a @JoinTable annotation
(with the same name) on both sides and this single join table gets 4 columns.
Can you zip a testproject and email it to me?
gr. Martin
Thomas wrote:
> Here is the getMappingXML():
>
> <class entity-name="Oresource" abstract="false" lazy="false"
> discriminator-value="Oresource" table="`ORESOURCE`">
>
> <bag name="resourceCategories" lazy="true" cascade="refresh"
> inverse="true" table="`ORSRC_RESRCECTEGRY`">
> <key/>
> <many-to-many entity-name="ResourceCategory" unique="false"
> foreign-key="ORSRC_RSRCCTEGRIES"/>
> </bag>
>
>
> <class entity-name="ResourceCategory" abstract="false" lazy="false"
> discriminator-value="ResourceCategory" table="`RESOURCECATEGORY`">
>
> <bag name="resources" lazy="false" cascade="all"
> table="`RSRCECTEGRY_RESRCE`">
> <key/>
> <many-to-many entity-name="Oresource" unique="false"
> foreign-key="RSRCCTEGRY_RESRCES"/>
> </bag>
>
> Thomas a écrit :
>> Ok, I have add a @JoinTable(name="RSRCECTEGRY_RESRCE") on both side
>> the result is a table RSRCECTEGRY_RESRCE with 4 columns columns, 2
>> with Resource id and 2 with ResourceCategory id
>> I know that we can also force column name, BUT
>> I have also a table called ORSRC_RESRCECTEGRY. Can it be teneo that
>> add this relation in my back ???
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> Normally Teneo should detect the mtm and create one jointable if both
>>> sides are non-indexed. What are the tablenames?
>>>
>>> There are no other annotations on the two ereferences?
>>>
>>> You can set a @JoinTable(name="myJoinTable") on both sides with the
>>> same join table name. Then both sides should use the same jointable.
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> Response in your message
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> Indexed mtm relations with one join table are not supported by
>>>>> hibernate:
>>>>> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+indexed+many-to-many+(nm)+relations
>>>>>
>>>>> a solution is to make both sides non-indexed by setting
>>>>> indexed=false on the association. But then you can't predict the
>>>>> order in which the elements are returned.
>>>> Oh yes, I have forgotten this specific teneo property.
>>>> But ever with that property, I have 2 tables, without indexes now.
>>>> Is the action of changing the name of a table (as resource is a key
>>>> word for oracle we use OResource instead) can make this behavior?
>>>>
>>>>>
>>>>> I am not sure why the repeated column exception occurs... Did you
>>>>> set the @JoinTable annotation on both sides?
>>>> No, it was on one side.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> Hello (Martin ? ;),
>>>>>>
>>>>>> A strange stuff with teneo and ManyToMany bidirectionnal relations
>>>>>>
>>>>>> I have a bidirectionnal ManyToMany between Resource (table
>>>>>> ORESOURCE) and ResourceCategory
>>>>>> I put on the ManyToMany of Resource a mappedBy as I want the
>>>>>> ResourceCategory would be the master.
>>>>>> On the generated database, I have 2 tables of relation
>>>>>> one call ORSRC_RESRCECTEGRY with a composite id on the id of
>>>>>> ORESOURCE and an index
>>>>>> one other call RSRCECTEGRY_RESRCE with a composite id on the id of
>>>>>> ResourceCategory and an index
>>>>>> It works with those both association, but why is there not only
>>>>>> one relation table with a composite id on id of OResource and the
>>>>>> id of Resource Category ???
>>>>>>
>>>>>>
>>>>>> And if I try to force the JoinTable to be on both ID with this
>>>>>> annotation
>>>>>> @JoinTable(
>>>>>> joinColumns=@JoinColumn(referencedColumnName=ID)
>>>>>> inverseJoinColumns=@JoinColumn(referencedColumnName=ID)
>>>>>> )
>>>>>> I have this error:
>>>>>> Repeated column in mapping for collection:
>>>>>> ResourceCategory.resources column: NULL
>>>>>>
>>>>>> Thanks for the light you can give to me
>>>>>>
>>>>>> Thomas
>>>>>
>>>>>
>>>
>>>
--
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: Thu Mar 28 14:34:56 GMT 2024
Powered by FUDForum. Page generated in 0.02454 seconds
|