geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Aufdencamp <m...@aufdencamp.com>
Subject RE: EJB 2.1 CMR Bi-Directional with Compound Key
Date Wed, 30 May 2007 19:54:46 GMT
<div>
Thanks for the response Gianny.&nbsp; I've wacked out a small demo that
I'm working on right now with a session facade, the three beans, and the database tables.&nbsp;
I'll let you all know how it goes:)</div>
<div>&nbsp;</div>
<div>
I'm planning on hittting EJB 3.0 hard once I understand this.&nbsp; I
want to comprehend the legacy way first!<BR></div>
<div   name="wmMessageComp"><BR><BR>
<BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" webmail="1">--------
Original Message --------<BR>Subject: Re: EJB 2.1 CMR Bi-Directional with Compound Key<BR>From:
Gianny Damour &lt;gianny.damour@optusnet.com.au&gt;<BR>Date: Wed, May 30, 2007
7:07 am<BR>To: user@geronimo.apache.org<BR><BR><PRE>Hi Mark,

I had a look to the openejb-jar DD and I think you need to drop the  
&lt;foreign-key-column-on-source/&gt; element from the Committee- 
CommitteeMembers relation. This optional element means that the  
foreign key columns declared in the following &lt;cmr-field-mapping&gt;  
elements are defined by the CMP declared by &lt;relationship-role-source&gt;.

So, this should work:

&lt;ejb-relation&gt;
   &lt;ejb-relation-name&gt;Committee-CommitteeMembers&lt;/ejb-relation-name&gt;
   &lt;ejb-relationship-role&gt;
     &lt;ejb-relationship-role-name&gt;Committee-has-many-CommitteeMembers&lt;/

ejb-relationship-role-name&gt;
     &lt;relationship-role-source&gt;
       &lt;ejb-name&gt;CommitteeEntity&lt;/ejb-name&gt;
     &lt;/relationship-role-source&gt;
     &lt;cmr-field&gt;
       &lt;cmr-field-name&gt;committeeMembers&lt;/cmr-field-name&gt;
     &lt;/cmr-field&gt;
     &lt;role-mapping&gt;
       &lt;cmr-field-mapping&gt;
         &lt;key-column&gt;CommitteeId&lt;/key-column&gt;
         &lt;foreign-key-column&gt;CommitteeId&lt;/foreign-key-column&gt;
       &lt;/cmr-field-mapping&gt;
     &lt;/role-mapping&gt;
   &lt;/ejb-relationship-role&gt;
&lt;/ejb-relation&gt;

Also, you do not need to declare both sides of a relationship: the  
above is enough to declare the CMR mapping for the Committee- 
CommitteeMembers relation.

BTW, I strongly recommend you to upgrade to OpenEJB3: this should be  
a seamless migration from a CMP perspective as the OpenEJB guys have  
done a fantastic work at writing an OpenEJB2 schema converter.

Thanks,
Gianny

On 30/05/2007, at 1:07 AM, Mark Aufdencamp wrote:

&gt; I could really use some help on this!  I have a two Entity beans  
&gt; with a bi-directional relationship, committees and  
&gt; committee_members.  Committees has a single field primary key of  
&gt; committeeId.  Committee_members has a compound primary key of  
&gt; CommitteeId+UserId.  A Foreign Key constraint has been defined for  
&gt; the committee_members table based on the committeeId.  I can't seem  
&gt; to get this to deploy and believe it's my openejb-jar.xml  
&gt; deployment descriptor in the &lt;relationship&gt; section.  I've looked 

&gt; at examples from JBoss and Sun, so I'm fairly certain my ejb- 
&gt; jar.xml is correct.
&gt;
&gt; Does anyone have a working example of a bi-directional relatioship  
&gt; where the many table has a compound key that I can take a look at?
&gt;
&gt; Where can I find documentation on how OpenEJB and TranQL interact  
&gt; to create the O/R map?
&gt;
&gt; This knowledge are really seems to be lacking documentation in  
&gt; Geronimo.  I'd really like to draw some pretty pictures of tables  
&gt; and beans with the seven different relationship types defined for  
&gt; EJB 2.1.  This would be good preliminary work for documenting EJB  
&gt; 3.0 examples.  Please help me learn, so I can contribute:)
&gt;
&gt; TIA,
&gt; Mark Aufdencamp
&gt; <A onclick="Popup.composeWindow('pcompose.php?sendto=Mark%40Aufdencamp.com');
return false;" href="http://email.secureserver.net/pcompose.php?aEmlPart=0&amp;type=reply&amp;folder=INBOX.Apache.Geronimo.Users&amp;uid=108#Compose">Mark<B></B>@Aufdencamp.com</A>

</PRE></BLOCKQUOTE></DIV>


Mime
View raw message