2 Replies Latest reply on Mar 13, 2004 6:55 AM by Alexey Loubyansky

    Realationship

    Alex Newbie

      I have tone CMP Bean whis relationship to itself.

      <ejb-name>Nodes</ejb-name>
      <table-name>Nodes</table-name>
      <cmp-field>
      <field-name>nodeID</field-name>
      <column-name>nodeID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>parentID</field-name>
      <column-name>parentID</column-name>
      </cmp-field>

      --------------------------------
      and relatinship
      one to many.
      ejb-jar.xml:
      <ejb-relation>
      <ejb-relation-name>nodes-nodes</ejb-relation-name>
      <ejb-relationship-role>
      nodes
      <ejb-relationship-role-name>NodesRelationshipRole</ejb-relationship-role-name>
      One
      <relationship-role-source>
      nodes
      <ejb-name>Nodes</ejb-name>
      </relationship-role-source>
      <cmr-field>
      nodes
      <cmr-field-name>nodes</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      nodes
      <ejb-relationship-role-name>NodesRelationshipRole1</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      nodes
      <ejb-name>Nodes</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      --------------------------------------
      and jbosscmp-jdbc.xml:
      <ejb-relation>
      <ejb-relation-name>nodes-nodes</ejb-relation-name>
      <foreign-key-mapping />
      <ejb-relationship-role>
      <ejb-relationship-role-name>NodesRelationshipRole</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>nodeID</field-name>
      <column-name>parentID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>NodesRelationshipRole1</ejb-relationship-role-name>
      </ejb-relationship-role>
      </ejb-relation>
      -----------------------------
      when I next mesods:
      Nodes nodes = nodesHome.findByPrimaryKey(new Long(1));
      Collection collection = nodes.getNodes();
      Iterator iterator = collection.iterator();
      iterator.getNaxt();
      iterator.remove();

      I see,that forein key field that coresponding to the records that i remove,set to null value, but i don't do "nodes.setNodes(collection).
      Is't normall behavior for Jboss3.2.3?