緊急求助benq:JBoss中cmr時複合關鍵字類的foreign keys mapping如何配置

shy613發表於2004-02-19

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不支援?

相關文章