紧急求助benq:JBoss中cmr时复合关键字类的foreign keys mapping如何配置

04-02-19 shy613

individualDetailBean-->companyBranchBean,单向,many to one,CompanyBranchBean的masterID、branchID皆为主键,故定义CompanyBranchPK,略去<primary-field>,配置文件如下:

(1). ejb-jar.xml

<entity>

<display-name>CompanyBranchBean</display-name>

<ejb-name>CompanyBranchBean</ejb-name>

<local-home>org.vp.eservice.user.ejb.CompanyBranchLocalHome</local-home>

<local>org.vp.eservice.user.ejb.CompanyBranchLocal</local>

<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>

<reentrant>False</reentrant>

<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>

</entity>

(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>

部署时JBoss报错: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,将field改位置也不行,定是jbosscmp-jdbc.xml未写对。

另外,此job中还有自增量的问题:addressBean的主键addressID为自增量,故jbosscmp-jdbc.xml设为unknow pk,而在foreign keys mapping时,其它Bean找不到addressID,jbosscmp-jdbc.xml不知怎样写,或是JBoss不支持?

猜你喜欢