openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gene Woo" <gene...@gmail.com>
Subject Re: OneToMany(mappedBy...) special case
Date Fri, 14 Dec 2007 07:03:02 GMT
Hi,

PartyRole could have 2 fields in Set<PartyRelationship>:
* private @OneToMany(mappedBy="primaryPartyRole")Set<PartyRelationship>
primaryRelationships;
 private @OneToMany(mappedBy="secondaryPartyRole")Set<PartyRelationship>
secondaryRelationships;*

then you could have a method to merge then together. Set is quite easy to
merge, right?
*public Set<PartyRelationship> getPartyRelationships();*

In my opinion, the combination of primaryRelationships and
sencondaryRelationships is a business view of PartyRole model. So you
probably have separate field for persistence purpose.

Thanks,

Gene.

On Dec 14, 2007 6:54 AM, Alexander Saint Croix <saintx.opensource@gmail.com>
wrote:

> Hello again,
>
> I have been having a little difficulty determining how to map a special
> case
> of a OneToMany relationship between two of my entity beans.
>
> The first bean, PartyRole, defines a OneToMany relationship to the second
> bean, PartyRelationship by way of a Set<PartyRelationship>.  The second
> bean, PartyRelationship, has TWO mappings back to PartyRole.
> PrimaryPartyRole and SecondaryPartyRole.  PrimaryPartyRole and
> SecondaryPartyRole.  Each of these mappings should be ManyToOne.  The
> relationship is bidirectional in each case.
>
> However, I'm not sure whether there is a way to define the "mappedBy"
> annotation attribute in PartyRole to correctly identify each field as
> owning
> side of their respective relationship.  Can I say
> @OneToMany(mappedBy="primaryPartyRole, secondaryPartyRole")?  Something
> tells me no.
>
> If this is not possible, is there another way to accomplish this?  Perhaps
> an object that represents a link table between these two entities?
>
> Kind regards,
> --
> Alexander R. Saint Croix
>



-- 
Best Regards,

Gene Woo

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