15:45:08,215 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=Table1,service=EJB org.jboss.deployment.DeploymentException: Role: Table1-da-Table2 with multiplicity many using foreign-key mapping is not allowed to have key-fields
Ok. look at your DD : <ejb-relationship-role > <ejb-relationship-role-name>table2-da-table1</ejb-relationship-role-name> <multiplicity>Many</multiplicity> <relationship-role-source > <ejb-name>Table1</ejb-name> </relationship-role-source> <cmr-field > <cmr-field-name>table2</cmr-field-name> </cmr-field> </ejb-relationship-role> Table1 should have multiplicity One not many. look at your code, Table1 has two methods : Collection getTables2( ) // and setter so this side of the relation should be :
and the second side is :
I am sure that you are using local view, right ? make sure that you are using the same relation name in jboss.xml my advice for you : buy a good EJB book and don't use xdoclet if you are not sure where to set the attributes. xdoclet may add to your life tons of heartace if you are not sure about the use and the location of the attributes. hope this help.
theserverside.com has the complete copy of Mastering Enterprise Java Beans 2.0 if you are entresting in EJB 2.1 , I will recommend EJB 4 edition by Richard Monson Haefel. it is a great book and has changed my mind about EJB. good luck.
When I deploy that I receive this message: 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=User-Address
Then in jbosscmp-jdbc I insert this: .. <ejb-relationship-role-name>User-has-many-Addresses</ejb-relationship-role-name> <key-fields> <key-field> <field-name>user_id</field-name> <column-name>id</column-name> </key-field> </key-fields> ..
And I receive this:
Role 'User-has-many-Addresses' on Entity Bean 'User' : CMP field for key not found: field name='id'