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

[427 byte] By [benzhang0001a] at [2007-10-2 16:35:33]
# 1
I meant EJB nt EJC :)
benzhang0001a at 2007-7-13 17:41:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

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>

a_mathewa at 2007-7-13 17:41:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Thanks!

So I do not need to map the Hous field to the table in the database directly in the weblogic-ejb-jar.xml, (of course I could not, no such field). Instead using the JB - relation, weblogic will base on the relationship and the House database map (EJB - to table), figure this field out ..

Haha ..

I will give a try!

Ben

benzhang0001a at 2007-7-13 17:41:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...