user manual
162 BES Developer’s Guide
Container-Managed Persistence in Borland Enterprise Server
<ejb-relationship-role>
<relationship-role-source>
<ejb-name>SpecialInfo</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
</relationships>
CASE 2: a bidirectional one-to-many relationship.
Here, we have a Customer entity bean with a primary key, CUSTOMER_NO, that is
also a foreign key in an Order entity bean. We want the Borland EJB Container
to manage this relationship. The Customer bean uses a field called "orders" that
links a customer to his orders. The Order bean uses a field called "customers"
for linking in the reverse direction. First, we define the relationship and its
source for the first direction: setting up the mapping for a Customer's orders.
<relationships>
<ejb-relation>
<ejb-relationship-role>
<relationship-role-source>
<ejb-name>Customer</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>orders</cmr-field-name>
Then, we add the table references to specify the relationship between the
tables. We're basing this relationship on the CUSTOMER_NO column, which is a
primary key for Customer and a foreign key for Orders:
<table-ref>
<left-table>
<table-name>CUSTOMER</table-name>
<column-list>
<column-name>CUSTOMER_NO</column-name>
</column-list>
</left-table>
<right-table>
<table-name>ORDER</table-name>
<column-list>
<column-name>CUSTOMER_NO</column-name>
</column-list>
</right-table>
</table-ref>
</cmr-field>
</ejb-relationship-role>
We're not quite done with our relationship, though. Now, we need to complete
it by specifying the relationship role for the other direction:
<ejb-relationship-role>
<relationship-role-source>
<ejb-name>Customer</ejb-name>
</relationship-role-source>










