many-to-many relation with xdoclet
eddie07 Jun 23, 2003 3:39 PMI am not able to use xdoclet tags to generate the correct jbosscmp-jdbc.xml file for a (bidirectional) m-n-relation.
This is what I am testing, but jbosscmp-jdbc.xml is not generated (unfortunately without an error message, I am using eclipse).
part of the code:
EBUserBean:
/**
* @ejb.bean name="EBUser"
* jndi-name="EBUserTestBean"
* type="CMP"
* primkey-field="user_id"
* schema="UserSchema"
* cmp-version="2.x"
*
* @ejb.persistence
* table-name="USERS"
**/
...
public abstract class EBUserBean implements EntityBean {
...
/**
* @ejb.interface-method
*
* @ejb.relation
* name="UserGroupRelation"
* role-name="UserhasGroups"
* target-role-name="GroupsForUser"
* target-ejb="EBGroup"
*
* @jboss.relation-mapping style="relation-table"
*
* @jboss.relation-table table-name="USERGROUPRELATION"
*
* @jboss.relation related-pk-field = "group_id"
* fk-column = "USER_ID"
*
*/
public abstract java.util.Collection getGroups();
public abstract void setGroups(java.util.Collection groups);
EBGroupBean:
/**
* @ejb.bean name="EBGroup"
* jndi-name="EBGroupBean"
* type="CMP"
* primkey-field="group_id"
* schema="GroupSchema"
* cmp-version="2.x"
*
* @ejb.persistence
* table-name="GROUPS"
*
**/
...
public abstract class EBGroupBean implements EntityBean {
...
/**
* @ejb.interface-method
*
* @ejb.relation
* name="UserGroupRelation"
* role-name="GroupsForUser"
* target-role-name="UserhasGroups"
* target-ejb="EBUser"
*
* @jboss.relation-table table-name="USERGROUPRELATION"
*
* @jboss.relation related-pk-field = "user_id"
* fk-column = "GROUP_ID"
*
*/
public abstract java.util.Collection getUsers();
public abstract void setUsers(java.util.Collection users);
It's working for a unidirectional relation:
EBUserBean:
/**
* @ejb.interface-method
*
* @ejb.relation
* name="UserGroupRelation"
* role-name="UserhasGroups"
* target-role-name="GroupsForUser"
* target-ejb="EBGroup"
*
* @jboss.relation-mapping style="relation-table"
*
* @jboss.relation-table table-name="USERGROUPRELATION"
*
* @jboss.relation related-pk-field = "group_id"
* fk-column = "USER_ID"
*
* @jboss.target-relation related-pk-field = "user_id"
* fk-column = "GROUP_ID"
*
*/
public abstract java.util.Collection getGroups();
public abstract void setGroups(java.util.Collection groups);
EBGroupBean:
/**
* @ejb.interface-method
*
*/
public abstract java.util.Collection getUsers();
public abstract void setUsers(java.util.Collection users);
What am I doing wrong here?
Or can someone show me a working example?
BTW, the same problem occurs for a 1-n relation, I am only able to use it unidirectional.
Eddie