• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity CMP Mapping Questions

 
John Smith
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:

I am currently using Weblogic 8.1.
Currently, the ejb-jar.xml contains the following:
<ejb-relation>
<ejb-relation-name>Customer-HomeAddress</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>
Customer-has-a-Address
</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>CustomerEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>homeAddress</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>
Address-belongs-to-Customer
</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>AddressEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>


In the weblogic-cmp-rdbms-jar.xml file:

<weblogic-rdbms-relation>
<relation-name>Customer-HomeAddress</relation-name>
<weblogic-relationship-role>
<relationship-role-name>Customer-has-a-Address</relationship-role-name>
<relationship-role-map>
<column-map>
<foreign-key-column>ADDRESS_ID</foreign-key-column>
<key-column>ID</key-column>
</column-map>
</relationship-role-map>
</weblogic-relationship-role>
</weblogic-rdbms-relation>

In the Address table, it has an ADDRESS_ID field.
What I am confused about is where in the weblogic-cmp-rdbms-jar.xml
and ejb-jar.xml file will indicated that the Customer table has a foreign key of ADDRESS_ID field. Not the other way around of the Address table has a foreign key of "CustomerId".

The reason I am asking this is because if you look at the weblogic-cmp-rdbms-jar.xml and ejb-jar.xml below I can't tell if in the Phones table there is a foreign key to Customer or inside the Customer table there is a foreign key to Phones:

Inside the weblogic-cmp-rdbms-jar.xml file :

<weblogic-rdbms-relation>
<relation-name>Customer-Phones</relation-name>
<weblogic-relationship-role>
<relationship-role-name>Phone-belongs-to-Customer</relationship-role-name>
<relationship-role-map>
<column-map>
<foreign-key-column>CUSTOMER_ID</foreign-key-column>
<key-column>ID</key-column>
</column-map>
</relationship-role-map>
</weblogic-relationship-role>
</weblogic-rdbms-relation>

Inside the ejb-jar.xml:
<ejb-relation>
<ejb-relation-name>Customer-Phones</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>
Customer-has-many-Phone-numbers
</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>CustomerEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>phoneNumbers</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>
Phone-belongs-to-Customer
</ejb-relationship-role-name>
<multiplicity>many</multiplicity>
<relationship-role-source>
<ejb-name>PhoneEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>

Yours,

Curious
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!