Dain Sundstrom wrote:
>>I am playing with the current sources and testing a 1 to many
>>relationship. I have the following two tables
>>
>>order with pk: int objectid
>>
>
> ok
>
>
>>and
>>orderdetail
>>pk: int order_oid,int line_num
>>
>
> Does order detail have a compund key using both order_oid and line_num?
>
Yes the primary key is order_oid,line_num
>
>>The link..
>>order_oid=objectid
>>
>
> Ok, foriegn-key style mapping.
>
>
>>There is a 1 to many relationship between Order and orderdetail. When
>>you go to access the collection it tries to look up the orderdetail
>>lines with order_oid_objectid.
>>
>
> Yep, that is the auto generated foreign key name.
The forgein key name is the field name! From the logs ...
You generate ..
[CMP,DEBUG] FindByForeignKey command executing: SELECT line_number,
order_oid FROM orderdetail WHERE order_oid_objectid=?
This should be
SELECT line_number, order_oid FROM orderdetail WHERE order_oid=?
>
>
>>In
>>
> org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
>
>>it always appends the the other side of the relationships field to the
>>query fieldname.
>>
>
> The goal is to generate a unique field name.
>
the field is unique
>
>>This does not seem right, if there is another field
>>name that is the forgien key then I should specify it otherwise it
>>should default to the selected field.
>>
>
> What do you mean by selected field?
>
>
>>I guess you would run into
>>problems if the key was a composite and you had to match the two up.
>>Flips through the spec .... Nope the spec only alllows for 1 field to be
>>the forgein key
>>
>
> What spec? If the parent table has a compound key or a single key field
> that maps to multiple columns (dependent value class), you will need
> multiple foreign key fields.
>
No. The forgein key mapping can not be a composite key. It has to be a 1
to 1 mapping (Otherwise how would you map a foreign key, which field
goes to which field?) . The primary key can be composite but the foreign
keys can not. Here is my relation section
<relationships>
<ejb-relation>
<ejb-relation-name>Order-OrderDetail</ejb-relation-name>
<ejb-relationship-role>
<multiplicity>Many</multiplicity>
<cascade-delete/>
<relationship-role-source>
<ejb-name>orderdetail</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>transferhead_oid</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>order</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>orderdetails</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development