Question with ManyToMany relation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question with ManyToMany relation

John Arevalo
Hi list,

I have 2 Entities (Mapped from AS400)

TableA:
field1A
field2A
field3A
primary key(field1A,field2A,field3A)  --- TableAPK @EmbeddedId

TableB:
field1B
field2B
primary key(field1B,field2B)  --- TableBPK @EmbeddedId

next entity is relationship ManyToMany between TableA  and TableB

TableAB
field1B
field1A
field2A
field3A
primary key(field1B,field1A,field2A,field3A)

How can i create EntityAB? 3rd table only have field1B as related
field with TableB.

Thanks for your replies.

Regards,
--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Reply | Threaded
Open this post in threaded view
|

Re: Question with ManyToMany relation

jamesssss
This seems a little odd, if B's primary key is both 1B ad 2B, then how can the join table only have 1B?  Is 1B unique, if so then why do you require 2B in the primary key?

In general EclipseLink does support using alternate keys in a m-m, but JPA does not.  You can edit/define the ManyToManyMapping using a DescriptorCustomizer and the code API.  Just add only the 1B field, however if 1B is not unique, I'm not sure how you intend this to function.


john arevalo wrote
Hi list,

I have 2 Entities (Mapped from AS400)

TableA:
field1A
field2A
field3A
primary key(field1A,field2A,field3A)  --- TableAPK @EmbeddedId

TableB:
field1B
field2B
primary key(field1B,field2B)  --- TableBPK @EmbeddedId

next entity is relationship ManyToMany between TableA  and TableB

TableAB
field1B
field1A
field2A
field3A
primary key(field1B,field1A,field2A,field3A)

How can i create EntityAB? 3rd table only have field1B as related
field with TableB.

Thanks for your replies.

Regards,
--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
Reply | Threaded
Open this post in threaded view
|

Re: Question with ManyToMany relation

John Arevalo
2008/10/8 James Sutherland <[hidden email]>:

>
> This seems a little odd, if B's primary key is both 1B ad 2B, then how can
> the join table only have 1B?  Is 1B unique, if so then why do you require 2B
> in the primary key?
>
> In general EclipseLink does support using alternate keys in a m-m, but JPA
> does not.  You can edit/define the ManyToManyMapping using a
> DescriptorCustomizer and the code API.  Just add only the 1B field, however
> if 1B is not unique, I'm not sure how you intend this to function.
>
>
>
> john arevalo wrote:
>>
>> Hi list,
>>
>> I have 2 Entities (Mapped from AS400)
>>
>> TableA:
>> field1A
>> field2A
>> field3A
>> primary key(field1A,field2A,field3A)  --- TableAPK @EmbeddedId
>>
>> TableB:
>> field1B
>> field2B
>> primary key(field1B,field2B)  --- TableBPK @EmbeddedId
>>
>> next entity is relationship ManyToMany between TableA  and TableB
>>
>> TableAB
>> field1B
>> field1A
>> field2A
>> field3A
>> primary key(field1B,field1A,field2A,field3A)
>>
>> How can i create EntityAB? 3rd table only have field1B as related
>> field with TableB.
>>
>> Thanks for your replies.
>>
>> Regards,
>> --
>> John Arévalo
>> GNU/Linux User #443701
>> http://counter.li.org/
>>
>
>
> -----
> ---
> http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
> http://www.eclipse.org/eclipselink/
>  EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
> TopLink
> Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
> http://wiki.oracle.com/page/TopLink TopLink
> Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
> http://www.nabble.com/EclipseLink-f26430.html EclipseLink
> Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
> --
> View this message in context: http://www.nabble.com/Question-with-ManyToMany-relation-tp19862493p19879353.html
> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> eclipselink-users mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Thanks for your reply James,

AS400 is extremly odd, i can't alter this poor structure.

i solved temporally with NamedQuery in order to build my
getTableBCollection Method,

Regards
--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users