CMR between two entity beans:
If I define it graphically, I get the following DD snippet:
<ejb-relation>
<ejb-relation-name>userApp-userEntity</ejb-relation-name>
<ejb-relationship-role>
<description>userApp</description>
<ejb-relationship-role-name>UserAppRelationshipRole1</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<description>userApp</description>
<ejb-name>UserApp</ejb-name>
</relationship-role-source>
<cmr-field>
<description>userEntity</description>
<cmr-field-name>userEntity</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<description>userEntity</description>
<ejb-relationship-role-name>userEntityRelationshipRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<description>userEntity</description>
<ejb-name>userEntity</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
If I then deploy, I get:
09:40:27,738 WARN [ServiceController] Problem starting
service jboss.j2ee:jndiName=ApplicationRole,service=EJB
org.jboss.deployment.DeploymentException: Role:
UserAppRelationshipRole1 with multiplicity many using
foreign-key mapping is not allowed to have key-fields
at
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKeyFields(JDBCRelationshipRoleMetaData.java:357)
at
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.init(JDBCRelationshipRoleMetaData.java:157)
at
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.<init>(JDBCRelationMetaData.java:313)
at
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:383)
at
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:75)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:677)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:389)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:339)
at
org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:198)
...etc...
I can not get past this error. Is it a bug? I'm new
to CMP, so is it a problem with the DD?
Thanks,
Dave
Logged In: YES
user_id=437534
Okay, the openTool is putting the key-field element in the
wrong side of the relationship - I have a many-to-one
relationship, and the tool is putting the key-field element
on the many side.
This would be fine if it were a one-to-many relationship,
but this one is the inverse.
So to fix, I had to move the key-field element to the other
role in the relationship, and change the field and column
names to match their proper labels in the second
table/Entity Bean.
Great tool, otherwise. But that stumped me for a day.
Please fix this, if possible...
Dave