1 Reply Latest reply on Jan 29, 2002 1:59 AM by Alexander Lepekhine

    Many-to-Many CMR Relationship Issue

    Brian Hand Newbie

      Hi,

      I am hitting a strange issue. I am running JBoss 3.0 alpha. as downloaded from the website, not the CVS version. I am attempting to get a many to many relationship working. I have the CMP documentation and "attempted" to follow it. However, after much configuration I seem to not get this working. The problem is that once the get method that drives the relationship is called, JBoss looks like it hangs for LONG time, does nothing, and then the connection pool times out causing a transaction rollback exception. BTW long time means approx 5 min.

      The question, did the non CVS version of JBoss 3.0 alpha implement many - to - many relationships correctly or should I take a chance with the CVS version? I am attaching snipets of my files ejb-jar.xml and jbosscmp-jdbc.xml I am hoping, and have a strong feeling that it is my configuration. Can anyone shed some light on this please.

      One last thing. It is important to note that the ejb-jar.xml works correctly in weblogic. also the join table exists already in the database and should not be created. It is also of note that there is also other fields in the join table besides the key fields. This info may not amount to much but just thought I would toss it out anyways.

      here are the snipets

      ejb-jar.xml
      <ejb-relation>
      <ejb-relation-name>ShipmentUnit-Pallet</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>one-ShipmentUnit-Has-Many-Pallets</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>ShipmentUnitBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>pallets</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>one-Pallet-Has-Many-ShipmentUnits</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>PalletBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>shipmentUnits</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      and now for the jbosscmp-jdbc.xml
      <ejb-relation>
      <ejb-relation-name>ShipmentUnit-Pallet</ejb-relation-name>
      <table-mapping>
      <table-name>su_ptu</table-name>
      <create-table>false</create-table>
      <delete-table>false</delete-table>
      <ejb-relationship-role>
      <ejb-relationship-role-name>one-ShipmentUnit-Has-Many-Pallets</ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>tcn</field-name>
      <column-name>su_id</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>one-Pallet-Has-Many-ShipmentUnits</ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>id</field-name>
      <column-name>pal_id</column-name>
      </table-key-field>
      <table-key-field>
      <field-name>date</field-name>
      <column-name>pal_dt</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>
      </table-mapping>
      </ejb-relation>

        • 1. Re: Many-to-Many CMR Relationship Issue
          Alexander Lepekhine Newbie

          This feature doesn't concern with many-to-many relationship. It may be in one-to-one and one-to-many relationship too. There is something wrong in 3.0alpha with transaction management as I understand, so you can't call another EJB methods from post-create method of the bean. Put debug output before every line of your create and post-create methods and you will see, that your program hangs when you call method of another bean. Try to rewrite buisiness logic and avoid using post-create calls. As I can see from your deployment descriptor you use bidirectional relationsip. It is a luxury in many cases. In most tasks unidirectional relationship will be enough. Also add child to the existing bean by creating child and adding it to children in the master bean method.
          JBoss is free and it's developers love us. What more do we need? Lets wait for 3.0beta.