openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nat Gross" <>
Subject ManyToMany - with a twist
Date Tue, 21 Aug 2007 20:51:10 GMT
[In an existing ejb 2 application] I have an interesting manytomany

Class EntityA with a 1 field Integer pk can relate to other instances of
itself in more than one way.
Not only can it have many  EntityA children and have many EntityA parents it
can have the SAME EntityA Parent/Child more than once.
Each EntityA needs a reason as to why it relates to the other EntityA.
(Suppose EntityA is a Person that can relate to another Person in more than
one way, say a cousin,  a spouse, employer, business partner. [ahem<g>])
Currently I have a table, ARELATIONS, with three Integer fields: srcPK,
targetPK, relateType. All three fields make up the PK. Currently I am
manually controlling the joins of this table with EntityA. I would like to
utilize jpa to do this.

Also important to note is that it is not enough for the end-user to simply
fetch related EntityA records, the *reason* (relateType) is also important.

Basically I should be able to define two OneToMany Unidirectional
Collection<Arelations> fields in EntityA, but whatever I try with Toplink I
get different problems. (Basically, Toplink wants yet another intersection
table, which I don't want.)
I hope openjpa has a better solution.
Please adivse.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message