0 Replies Latest reply on Feb 18, 2004 1:25 AM by shy613

    composite keys class & foreign keys mapping

    shy613 Newbie

      Hi all,
      I trying to use composite Primary kay in PK class in Container Magaged Persistance(CMP).So please suggest me how are their deployment descripter.

      individualDetailBean-->companyBranchBea,undirectional,many to one

      (1). ejb-jar.xml

      <display-name>CompanyBranchBean</display-name>
      <ejb-name>CompanyBranchBean</ejb-name>
      <local-home>org.vp.eservice.user.ejb.CompanyBranchLocalHome</local-home>
      org.vp.eservice.user.ejb.CompanyBranchLocal
      <ejb-class>org.vp.eservice.user.ejb.CompanyBranchBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>org.vp.eservice.user.ejb.CompanyBranchPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>CompanyBranch</abstract-schema-name>
      <cmp-field>
      <field-name>masterID</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>branchID</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>name1</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>name2</field-name>
      </cmp-field>



      (2).jbosscmp-jdbc.xml
      <ejb-relation>
      <ejb-relation-name>individualDetail-companyBranch</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>IndividualDetailRelationshipRole</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>CompanyBranchRelationshipRole</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>branchID</field-name>
      <column-name>BranchID</column-name>
      </key-field>
      <key-field>
      <field-name>masterID</field-name>
      <column-name>MasterID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      DeploymentException:&#65306;Atleast one role of a foreign-key mapped relationship must have key fields (or <primkey-field> is missing from ejb-jar.xml): ejb-relation-name=individualDetail-companyBranch.



      Regards
      shy613