1 Reply Latest reply on Feb 12, 2003 11:32 AM by Leslie Liew Eng Chuan

    Problem in One-To-One relationship

    Leslie Liew Eng Chuan Newbie

      i have problem deploying my bean.

      following is my ejb-jar.xml file, mainly because i have problem defining relationship in jbosscmp.jdbc.xml based on the relationship defined in ejb-jar.xml.

      ------------
      <ejb-jar>
      <display-name>local_objects</display-name>
      <enterprise-beans>

      <display-name>OrderEJB2</display-name>
      <ejb-name>OrderEJB2</ejb-name>
      examples.local_objects.OrderHome
      examples.local_objects.Order
      <ejb-class>examples.local_objects.OrderBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      True
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>OrderBean</abstract-schema-name>
      <cmp-field><field-name>customerName</field-name></cmp-field>
      <cmp-field><field-name>orderID</field-name></cmp-field>
      <primkey-field>orderID</primkey-field>
      <ejb-local-ref>
      <ejb-ref-name>ejb/AddressEJB</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>examples.local_objects.AddressLocalHome</local-home>
      examples.local_objects.AddressLocal
      <ejb-link>AddressEJB</ejb-link>
      </ejb-local-ref>


      <display-name>AddressEJB</display-name>
      <ejb-name>AddressEJB</ejb-name>
      <local-home>examples.local_objects.AddressLocalHome</local-home>
      examples.local_objects.AddressLocal
      <ejb-class>examples.local_objects.AddressBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      True
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>AddressBean</abstract-schema-name>
      <cmp-field><field-name>addressID</field-name></cmp-field>
      <cmp-field><field-name>zip</field-name></cmp-field>
      <cmp-field><field-name>state</field-name></cmp-field>
      <cmp-field><field-name>city</field-name></cmp-field>
      <cmp-field><field-name>street</field-name></cmp-field>
      <primkey-field>addressID</primkey-field>

      </enterprise-beans>


      <ejb-relation>
      <ejb-relation-name></ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>OrderEJB2</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>OrderEJB2</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>shipAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>AddressEJB</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>AddressEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      <assembly-descriptor>
      <container-transaction>

      <ejb-name>AddressEJB</ejb-name>
      <method-name>*</method-name>


      <ejb-name>OrderEJB2</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>

      </ejb-jar>


      ------------

      what should i define the relationship in jbosscmp-jdbc.xml. following is the jbosscmp-jdbc.xml that i used which gave me exception when deploying it.

      ---------------------
      <jbosscmp-jdbc>


      java:/jdbc/OrderDataSource
      <datasource-mapping>mySQL</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <row-locking>false</row-locking>
      <!--read-ahead>false</read-ahead-->


      <enterprise-beans>

      <ejb-name>OrderEJB2</ejb-name>
      <table-name>order_table</table-name>
      <cmp-field>
      <field-name>orderID</field-name>
      <column-name>orderID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>customerName</field-name>
      <column-name>customerName</column-name>
      </cmp-field>



      <ejb-name>AddressEJB</ejb-name>
      <table-name>address_table</table-name>
      <cmp-field>
      <field-name>addressID</field-name>
      <column-name>addressID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>zip</field-name>
      <column-name>zip</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>state</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>city</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street</field-name>
      <column-name>street</column-name>
      </cmp-field>


      </enterprise-beans>


      <ejb-relation>

      <ejb-relation-name>Order-Address</ejb-relation-name>

      <foreign-key-mapping />

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      order-has-address
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>OrderEJB_shipAddress</field-name>
      <column-name>OrderEJB_shipAddress</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      address-belongs-to-order
      </ejb-relationship-role-name>
      <key-fields/>
      <fk-constraint>true</fk-constraint>
      <!--key-field>
      <field-name>addressID</field-name>
      <column-name>addressID</column-name>
      </key-field>
      </key-fields-->
      </ejb-relationship-role>

      </ejb-relation>


      </jbosscmp-jdbc>


      ---------------------

      please help.....