how mapping compoiste / compound field in weblogic
Hello,
If I have a EJC called student and another called house. they are many to one relation. Many students share a house. In the database I have a student table and one house table. In the Student bean, there is a mothed called:
public House getHouse().
in the weblogic-ejb-jar.xml, how to map this field house into the database table House., because it is not a signle field.
Thanks!
Ben
You can map the field using relationships.
CMR fields can be defined as follows :-
In ejb-jar.xml, give the mapping for the two EJBs StudentEJB and HouseEJB as follows:-
<ejb-relation>
<ejb-relation-name>HouseEJB-StudentEJB</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>house-has-students
</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>HouseEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>students</cmr-field-name>
<cmr-field-type>java.util.Collection
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>students-own-house
</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>StudentEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>house</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
In weblogic specific deployment descriptor, give as follows :-
<weblogic-rdbms-relation>
<relation-name>HouseEJB-StudentEJB</relation-name>
<weblogic-relationship-role>
<relationship-role-name>house-has-students</relationship-role-name>
<relationship-role-map>
<column-map>
<foreign-key-column>house</foreign-key-column>
<key-column>HouseNo</key-column>
</column-map>
<relationship-role-map>
</weblogic-relationship-role>