-
1. Re: How do I relate foreign key entity with relation table m
bigdaddy Oct 6, 2004 3:17 PM (in response to bigdaddy)To make this work will I have to explicitly create a customerId field in the Person entity bean and set the customerId within ejbPostCreate like this:
public abstract class PersonEJB implements EntityBean
{
public void ejbPostCreate (CustomerEJBLocal newCustomer) throws CreateException
{
setCustomer(newCustomer);
setCustomerId(newCustomer.getCustomerId());
}
...
}
Will I be able to add customer_id to jbosscmp-jdbc.xml like this:
<ejb-relation>
<ejb-relation-name>Person-Schedule</ejb-relation-name>
<relation-table-mapping>
<table-name>person_schedule</table-name>
<create-table>false</create-table>
</relation-table-mapping>
<ejb-relationship-role>
<ejb-relationship-role-name>Schedule-belongs-to-Person</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>id</field-name>
<column-name>schedule_id</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Person-has-Schedule</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>id</field-name>
<column-name>person_id</column-name>
</key-field>
<key-field>
<field-name>customerId</field-name>
<column-name>customer_id</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
Any assistance is appreciated.
Thanks.