Stephen,
This should really be posted to the JBossCMP list.
Here is a copy of a message I sent to a user on the that list that had a
similar problem:
-----------------------------------------------------------------------
Liam,
Here is an example:
<ejb-relation>
<ejb-relation-name>AB_OneToMany_Bi_FK</ejb-relation-name>
<foreign-key-mapping>
<ejb-relationship-role>
<ejb-relationship-role-name>A-has-Bs</ejb-relationship-role-name>
<foreign-key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>B-belongsto-A</ejb-relationship-role-name>
<foreign-key-fields>
<foreign-key-field>
<field-name>id</field-name>
<column-name>A_ID_PK</column-name>
</foreign-key-field>
</foreign-key-fields>
</ejb-relationship-role>
</foreign-key-mapping>
</ejb-relation>
In this example, A has many Bs. The A table will not contain any foreign
keys and the B table will have a foreign key for A's pk. The foreign key
column will be named A_ID_PK.
-----------------------------------------------------------------------
You put this in your jbosscmp-jdbc.xml file. If you are not familar with
this file send me a personal email and I will send you the full example from
my test code.
I will be finishing docs on how to configure relationships in ejb 2.0 soon,
but I will be working on a short contract starting tomorrow. This means
don't expect to see anything until next week.
-dain
----- Original Message -----
From: "Stephen Lewis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 01, 2001 4:53 AM
Subject: [JBoss-dev] Multiple CMP 2.x relationships to the same bean
> We have an entity bean for airline fares, each of which relates to two
> airports (departure and destination). We have tried to describe these
> relationships using the CMP 2.x features, by specifying two ejb-relations,
> "fare-departureairport" and "fare-destinationairport", in the ejb-jar.xml
> file.
>
> The CMP code tries to name both of the foreign key columns in the "Fare"
> table "airport_code", hence the creation of the fare table fails. We have
> tried overriding the column names in jbosscmp-jdbc.xml with no success. I
> have attached an excerpt from our ejb-jar.xml; any pointers gratefully
> received :)
>
> Stephen Lewis
>
> <ejb-relation>
> <ejb-relation-name>fare-departureairport</ejb-relation-name>
> <ejb-relationship-role>
>
>
<ejb-relationship-role-name>fare-has-departureairport</ejb-relationship-role
> -name>
> <multiplicity>Many</multiplicity>
> <relationship-role-source>
> <ejb-name>Fare</ejb-name>
> </relationship-role-source>
> <cmr-field>
> <cmr-field-name>departureAirport</cmr-field-name>
> </cmr-field>
> </ejb-relationship-role>
> <ejb-relationship-role>
>
>
<ejb-relationship-role-name>departureairport-belongs-to-fares</ejb-relations
> hip-role-name>
> <multiplicity>One</multiplicity>
> <relationship-role-source>
> <ejb-name>Airport</ejb-name>
> </relationship-role-source>
> </ejb-relationship-role>
> </ejb-relation>
> <ejb-relation>
> <ejb-relation-name>fare-destinationairport</ejb-relation-name>
> <ejb-relationship-role>
>
>
<ejb-relationship-role-name>fare-has-destinationairport</ejb-relationship-ro
> le-name>
> <multiplicity>Many</multiplicity>
> <relationship-role-source>
> <ejb-name>Fare</ejb-name>
> </relationship-role-source>
> <cmr-field>
> <cmr-field-name>destinationAirport</cmr-field-name>
> </cmr-field>
> </ejb-relationship-role>
> <ejb-relationship-role>
>
>
<ejb-relationship-role-name>destinationairport-belongs-to-fares</ejb-relatio
> nship-role-name>
> <multiplicity>One</multiplicity>
> <relationship-role-source>
> <ejb-name>Airport</ejb-name>
> </relationship-role-source>
> </ejb-relationship-role>
> </ejb-relation>
> </relationships>
>
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-development
>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development