0 Replies Latest reply on May 18, 2003 8:03 PM by destr0

    Xdoclet Many to Many

      I originally posted this in "Xdoclet on JBoss" but then realized that forum was for Xdoclet integration into jboss and not xdoclet questions. I apologize for the cross-post.

      I'm trying to figure out a many to many bidirectional relationship, but I can't seem to get the tags right. no matter what I do, the multiplicity in ejb-jar.xml is always generated as one on both sides, and in the tag in jbosscmp-jdbc.xml is always specified as <foreign-key-mapping> instead of creating a relation-table tag. Here's what I'm currently doing:

      Line from the shot Bean:

      /**
      * Set the Items that this shot is associated with.
      * @param itemCollection Collection containing the Items that are included in this
      * shot.
      *
      * @ejb.interface-method
      * @ejb.relation
      * name="Shot-Items"
      * role-name="Shot-has-many-Items"
      * multiple="yes"
      *
      * @jboss.relation-table
      * table-name="shot_membership"
      *
      * @jboss.relation
      * fk-column="item_id"
      * related-pk-field="itemId"
      */
      public abstract void setItems( Collection itemCollection );


      line from the Item Bean:

      /**
      * Set the Items that this shot is associated with.
      * @param itemCollection Collection containing the Items that are included in this
      * shot.
      *
      * @ejb.interface-method
      * @ejb.relation
      * name="Shot-Items"
      * role-name="Item-has-many-shots"
      *
      * @jboss.relation-table
      * table-name="shot_membership"
      *
      * @jboss.relation
      * fk-column="shot_id"
      * related-pk-field="shotId"
      */
      public abstract void setShots( Collection passShots );


      generated tag from ejb-jar.xml:


      <ejb-relation >
      <ejb-relation-name>Shot-Items</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Shot-has-many-Items</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Shot</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>items</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Item-has-many-shots</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Item</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>shots</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      </ejb-relation>



      here's the generated relationship section of jbosscmp-jdbc.xml


      <ejb-relation>
      <ejb-relation-name>Shot-Items</ejb-relation-name>

      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Shot-has-many-Items</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>shotId</field-name>
      <column-name>shot_id</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Item-has-many-shots</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>itemId</field-name>
      <column-name>item_id</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>


      any pointers would be helpful, I've been searching the net all day on this and all I can find is directions for one to one and one to many relationships