1 Reply Latest reply on Jan 19, 2004 10:55 PM by ebaskoro

    Getting problme in CMR

    dharam Newbie

      Hi All,

      I hav 2 entity beans called Category and Products. i m trying with CMR.
      in my ejb-jar.xml i hav defined relation s like this

      <!-- Relationships -->

      <ejb-relation>
      <ejb-relation-name>Categories-Products</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>categories-products</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Categories</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>products</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>products-categories</ejb-relationship-role-name>
      Many
      <cascade-delete/>
      <relationship-role-source >
      <ejb-name>Products</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>category</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      <!-- Relationships -->


      And in jbosscmp-jdbc.xml it is looking like this

      <!-- Relationships -->

      <ejb-relation>
      <ejb-relation-name>Categories-Products</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>categories-products</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>categoryID</field-name>
      <column-name>category</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>products-categories</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>

      <!-- Relationships -->

      Problem is that when i try to deploy these beans on Jboss3.2.0
      it is giving this error
      ------------------------------------------------------------------------------------
      org.jboss.deployment.DeploymentException: Atleast one role of a foreign-key mapped relationship must have key fields: ejb-relation-name=Categories-Products
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.(JDBCRelationMetaData.java:321)
      ..................
      ------------------------------------------------------------------------------------

      where i m missing in deployment descriptor....


        • 1. Re: Getting problme in CMR
          ebaskoro Newbie

          G'Day,

          On your DD, you specify for the role categories-products the field-name and column-name values as categoryID and category respectively.

          Your Category EJB needs to have the corresponding getCategoryID() and setCategoryID() methods and the created column should be category, which I doubt you would have.

          Change the column-name to categoryID.