1 Reply Latest reply on Aug 27, 2002 1:53 PM by Dain Sundstrom

    Many-to-Many CMP with a Custom PK Problems

    Matt Clark Newbie

      Hi,

      I have a simple many-to-many unidirectional relationship that I'm trying to set up, and I keep getting the following exception:

      org.jboss.deployment.DeploymentException: Both roles of a relation-table mapped relationship must have key fields: ejb-relation-name=Department-Item

      Here are the relevant parts of my DD:


      <![CDATA[No Description.]]>
      <ejb-name>Item</ejb-name>
      <local-home> com.paperandpunch.persist.catalog.ejb.ItemLocalHome
      </local-home>

      com.paperandpunch.persist.catalog.ejb.ItemLocal

      <ejb-class>
      com.paperandpunch.persist.catalog.ejb.ItemCMP
      </ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>
      com.paperandpunch.persist.catalog.ejb.ItemPK
      </prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Item</abstract-schema-name>
      <cmp-field>

      <![CDATA[Get identifier]]>

      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>

      <![CDATA[Getter for property name.]]>

      <field-name>name</field-name>
      </cmp-field>




      <![CDATA[No Description.]]>

      <ejb-name>Department</ejb-name>
      <local-home>
      com.paperandpunch.persist.catalog.ejb.DepartmentLocalHome
      </local-home>

      com.paperandpunch.persist.catalog.ejb.DepartmentLocal

      <ejb-class>
      com.paperandpunch.persist.catalog.ejb.DepartmentCMP
      </ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>
      com.paperandpunch.persist.catalog.ejb.DepartmentPK
      </prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Department</abstract-schema-name>
      <cmp-field>

      <![CDATA[Get bytes identifier]]>

      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>

      <![CDATA[Getter for property name.]]>

      <field-name>name</field-name>
      </cmp-field>



      <ejb-relation>
      <ejb-relation-name>Department-Item</ejb-relation-name>
      <ejb-relationship-role>
      <relationship-role-name>
      DepartmentsHaveItems
      </relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>Department</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>items</cmr-field-name>
      <cmr-field-type>
      java.util.Collection
      </cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <relationship-role-name>
      ItemsBelongToDepartments
      </relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>Item</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      My PK classes are pretty standard wrappers for a unique identifier (which is itself a wrapper for a byte array).

      I've tried searching through the forums, on the net, and in the docs to no avail. What I have seems to be right. Am I missing something?

      Thanks for the help!