懇請benq指點:JBoss中cmr時複合關鍵字類的foreign keys mapping問題,線上等待!

shy613發表於2004-02-24


individualDetailBean-->companyBranchBean,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未寫對,懇請指點。


相關文章