You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Gianny Damour <gi...@optusnet.com.au> on 2007/05/30 13:07:36 UTC
Re: EJB 2.1 CMR Bi-Directional with Compound Key
Hi Mark,
I had a look to the openejb-jar DD and I think you need to drop the
<foreign-key-column-on-source/> element from the Committee-
CommitteeMembers relation. This optional element means that the
foreign key columns declared in the following <cmr-field-mapping>
elements are defined by the CMP declared by <relationship-role-source>.
So, this should work:
<ejb-relation>
<ejb-relation-name>Committee-CommitteeMembers</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Committee-has-many-CommitteeMembers</
ejb-relationship-role-name>
<relationship-role-source>
<ejb-name>CommitteeEntity</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>committeeMembers</cmr-field-name>
</cmr-field>
<role-mapping>
<cmr-field-mapping>
<key-column>CommitteeId</key-column>
<foreign-key-column>CommitteeId</foreign-key-column>
</cmr-field-mapping>
</role-mapping>
</ejb-relationship-role>
</ejb-relation>
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:
> I could really use some help on this! I have a two Entity beans
> with a bi-directional relationship, committees and
> committee_members. Committees has a single field primary key of
> committeeId. Committee_members has a compound primary key of
> CommitteeId+UserId. A Foreign Key constraint has been defined for
> the committee_members table based on the committeeId. I can't seem
> to get this to deploy and believe it's my openejb-jar.xml
> deployment descriptor in the <relationship> section. I've looked
> at examples from JBoss and Sun, so I'm fairly certain my ejb-
> jar.xml is correct.
>
> Does anyone have a working example of a bi-directional relatioship
> where the many table has a compound key that I can take a look at?
>
> Where can I find documentation on how OpenEJB and TranQL interact
> to create the O/R map?
>
> This knowledge are really seems to be lacking documentation in
> Geronimo. I'd really like to draw some pretty pictures of tables
> and beans with the seven different relationship types defined for
> EJB 2.1. This would be good preliminary work for documenting EJB
> 3.0 examples. Please help me learn, so I can contribute:)
>
> TIA,
> Mark Aufdencamp
> Mark@Aufdencamp.com