1 Reply Latest reply on Apr 3, 2004 5:30 AM by Alexey Loubyansky

    CMR many to many w/ compound keys

    darren hartford Expert

      Hey all,
      Using Xdoclet to generate a many-to-many mapping of two tables that contain compound keys. When I try to deploy on Jboss 3.2.3 or JBoss 4.0DR3 I get an error (attached below). Does Jboss support many-to-many CMR mappings with compound keys?

      ==error==
      16:57:54,221 ERROR [EntityContainer] Starting failed
      org.jboss.deployment.DeploymentException: Role 'REMITTANCES-cmp20-has-ADJCLAIMS-
      cmp20' on Entity Bean 'Remittances' : CMP field for key not found: field name='rxsequence'
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.
      loadKeyFields(JDBCRelationshipRoleMetaData.java:432)
      ==end error==



      ===jbosscmp-jbdc.xml snippet===

      <ejb-relation>
      <ejb-relation-name>ADJCLAIMS-cmp20-RECONCILIATION-cmp20</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>RECONCILIATION-cmp20-has-ADJCLAIMS-cmp20</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ADJCLAIMS-cmp20-has-RECONCILIATION-cmp20</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>nabp</field-name>
      <column-name>CM_NABP</column-name>
      </key-field>
      <key-field>
      <field-name>thirdparty</field-name>
      <column-name>CM_THIRDPARTY</column-name>
      </key-field>
      <key-field>
      <field-name>rxnumber</field-name>
      <column-name>CM_RXNUMBER</column-name>
      </key-field>
      <key-field>
      <field-name>filldate</field-name>
      <column-name>CM_FILLDATE</column-name>
      </key-field>
      <key-field>
      <field-name>rxsequence</field-name>
      <column-name>CM_RXSEQUENCE</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>REMITTANCES-cmp20-ADJCLAIMS-cmp20</ejb-relation-name>
      <relation-table-mapping>
      <table-name>RECONCILIATION</table-name>
      <pk-constraint>true</pk-constraint>
      </relation-table-mapping>

      <ejb-relationship-role>
      <ejb-relationship-role-name>REMITTANCES-cmp20-has-ADJCLAIMS-cmp20</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>nabp</field-name>
      <column-name>CM_NABP</column-name>
      </key-field>
      <key-field>
      <field-name>thirdparty</field-name>
      <column-name>CM_THIRDPARTY</column-name>
      </key-field>
      <key-field>
      <field-name>rxnumber</field-name>
      <column-name>CM_RXNUMBER</column-name>
      </key-field>
      <key-field>
      <field-name>filldate</field-name>
      <column-name>CM_FILLDATE</column-name>
      </key-field>
      <key-field>
      <field-name>rxsequence</field-name>
      <column-name>CM_RXSEQUENCE</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ADJCLAIMS-cmp20-has-REMITTANCES-cmp20</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>nabp</field-name>
      <column-name>RM_NABP</column-name>
      </key-field>
      <key-field>
      <field-name>thirdparty</field-name>
      <column-name>RM_THIRDPARTY</column-name>
      </key-field>
      <key-field>
      <field-name>rxnumber</field-name>
      <column-name>RM_RXNUMBER</column-name>
      </key-field>
      <key-field>
      <field-name>filldate</field-name>
      <column-name>RM_FILLDATE</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>REMITTANCES-cmp20-RECONCILIATION-cmp20</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>RECONCILIATION-cmp20-has-REMITTANCES-cmp20</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>REMITTANCES-cmp20-has-RECONCILIATION-cmp20</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>nabp</field-name>
      <column-name>RM_NABP</column-name>
      </key-field>
      <key-field>
      <field-name>thirdparty</field-name>
      <column-name>RM_THIRDPARTY</column-name>
      </key-field>
      <key-field>
      <field-name>rxnumber</field-name>
      <column-name>RM_RXNUMBER</column-name>
      </key-field>
      <key-field>
      <field-name>filldate</field-name>
      <column-name>RM_FILLDATE</column-name>
      </key-field>
      </key-fields>

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

      ===end snippet===

      TIA for any help, this one has me stumped.
      -D

        • 1. Re: CMR many to many w/ compound keys
          Alexey Loubyansky Master

          Yes, it does support it.
          First of all

           <foreign-key-mapping/>
          


          hints that it is either 1:1 or 1:m. You something like
           <relation-table-mapping>
           <table-name>A_C</table-name>
           <datasource>java:/DefaultDS</datasource>
           <datasource-mapping>Hypersonic SQL</datasource-mapping>
           <create-table>true</create-table>
           <remove-table>true</remove-table>
           </relation-table-mapping>
          
          instead.