Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 89108 invoked from network); 14 Dec 2007 07:03:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Dec 2007 07:03:32 -0000 Received: (qmail 41881 invoked by uid 500); 14 Dec 2007 07:03:20 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 41863 invoked by uid 500); 14 Dec 2007 07:03:20 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 41854 invoked by uid 99); 14 Dec 2007 07:03:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2007 23:03:20 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of genewoo@gmail.com designates 209.85.146.183 as permitted sender) Received: from [209.85.146.183] (HELO wa-out-1112.google.com) (209.85.146.183) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Dec 2007 07:02:59 +0000 Received: by wa-out-1112.google.com with SMTP id m28so1630248wag.13 for ; Thu, 13 Dec 2007 23:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=zh7lZwCNOsQykCurYMlH/AMjtdJfBx9v0vT9JJ8mQi4=; b=AGQFL+9s2A96VC6eeE9V6MtwTwUglWNJvoYr6SrrhTQvLWlE2R6SaiWPXfJ0Q3zhFMBFeiwKcMqdGvltXvVtjiV7jfFGJIYThRASP5Gss3Dg4h96OaFHb0X/w+1m03qweJyfNaOyju2IXVZhheIKp6SvNd2oye+Gc+64hMBpTrg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=BwTLiyNO1/6JaHvWk++e2tQqSSsjxrSsgucic7II7bZ+qbSf4+yXLEBKG2KB3MdDw/gY5zJoxD2I0eRIYNPbrmJMWCcI2Lw0LEVWkpF5dwyrPb9i52oWmNQPaO+65l2KKS0PhIZ1NsX4ZlgP0MkBm2Ck2EnjDbqD7YXTJUeJ2PY= Received: by 10.115.110.6 with SMTP id n6mr1524641wam.92.1197615782183; Thu, 13 Dec 2007 23:03:02 -0800 (PST) Received: by 10.114.53.20 with HTTP; Thu, 13 Dec 2007 23:03:02 -0800 (PST) Message-ID: Date: Fri, 14 Dec 2007 15:03:02 +0800 From: "Gene Woo" To: users@openjpa.apache.org Subject: Re: OneToMany(mappedBy...) special case In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5538_13866198.1197615782176" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_5538_13866198.1197615782176 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, PartyRole could have 2 fields in Set: * private @OneToMany(mappedBy="primaryPartyRole")Set primaryRelationships; private @OneToMany(mappedBy="secondaryPartyRole")Set secondaryRelationships;* then you could have a method to merge then together. Set is quite easy to merge, right? *public Set 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 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. 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 ------=_Part_5538_13866198.1197615782176--