I'm running jboss-3.0.0RC3 with MySQL as a datasource and am having trouble with implementing a unidirectional, many-to-many relationship.
I have two EJBs, User and Role that have a many-to-many relationship. Users know about their Roles. Roles do not know about their Users.
My UserBean has these accessors for roles
public abstract Collection getRoles();
public abstract void setRoles(Collection roles);
In my jbosscmp-jdbc.xml file, I've declared the following:
<ejb-relation>
<ejb-relation-name>UserAssociateWithRoles</ejb-relation-name>
<relation-table-mapping>
<table-name>user_role0</table-name>
</relation-table-mapping>
<ejb-relationship-role>
<ejb-relationship-role-name>UserBeanToRoleBean</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>email</field-name>
<column-name>user</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>RoleBeanToUserBean</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>name</field-name>
<column-name>role</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
When I deploy my code (allowing jboss to create tables with names I've given), the table associating users and roles (
user_role0) is created. Great! Only thing is, the table is never populated. Instead, the table representing my User EJB(
user0 - which jboss created with a longblob column named
roles) is updated.
How do I get jboss to append rows to the
user_role0 table and not store the relationship to roles in the
user0 longblob column?