怎么关联为什么不对呢?

weida 2004-04-05 06:19:40
两个表分别为relationfirst,relationsecond.字段都为ID和name.ejb-jar.xml文件如下:
<ejb-jar >

<description><![CDATA[No Description.]]></description>
<display-name>Generated by XDoclet</display-name>
<enterprise-beans>
<entity >
<description><![CDATA[]]></description>

<ejb-name>RelationSecond</ejb-name>

<home>test.cmp.RelationSecondHome</home>
<remote>test.cmp.RelationSecond</remote>
<local-home>test.cmp.RelationSecondLocalHome</local-home>
<local>test.cmp.RelationSecondLocal</local>

<ejb-class>test.cmp.RelationSecondCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>second</abstract-schema-name>
<cmp-field >
<description><![CDATA[Returns the id]]></description>
<field-name>id</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Returns the name]]></description>
<field-name>name</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>

<entity >
<description><![CDATA[]]></description>

<ejb-name>RelationFirst</ejb-name>

<home>test.cmp.RelationFirstHome</home>
<remote>test.cmp.RelationFirst</remote>
<local-home>test.cmp.RelationFirstLocalHome</local-home>
<local>test.cmp.RelationFirstLocal</local>

<ejb-class>test.cmp.RelationFirstCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>first</abstract-schema-name>
<cmp-field >
<description><![CDATA[Returns the id]]></description>
<field-name>id</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Returns the name]]></description>
<field-name>name</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>
</enterprise-beans>

<relationships >
<ejb-relation >
<ejb-relation-name>twoRelation</ejb-relation-name>

<ejb-relationship-role>
<ejb-relationship-role-name>first-second</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source >
<ejb-name>RelationFirst</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>relationSec</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>

<ejb-relationship-role>
<ejb-relationship-role-name>second-first</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source >
<ejb-name>RelationSecond</ejb-name>
</relationship-role-source>
</ejb-relationship-role>

</ejb-relation>
</relationships>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>
在没有设置关联之前可以部署成功,可设置关联后就报错。我也在库表中设置了主外键,为什么还部署不成功?
org.jboss.deployment.DeploymentException: 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=twoRelation
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.<init>(JDBCRelationMetaData.java:347)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:470)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:75)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:706)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:409)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:357)
at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:342)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
...全文
36 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weida 2004-04-06
  • 打赏
  • 举报
回复
部署成功了,但是还有一个疑问,在用cmp做关联的时候是不是只能用外键的方式进行关联。
donghx1234 2004-04-05
  • 打赏
  • 举报
回复
先帮你UP一下吧!
satangf 2004-04-05
  • 打赏
  • 举报
回复
先帮你UP一下吧!很晚了!
  • 打赏
  • 举报
回复
jbosscmp-jdbc.xml没有或者没有写正确
weida 2004-04-05
  • 打赏
  • 举报
回复
自己up
fxywkj 2004-04-05
  • 打赏
  • 举报
回复
明天 帮呢看!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧