Problem with 1-N relationship
mesketh Sep 28, 2002 6:25 AMI have a problem with a fairly simple 1-N relationship. Here's the trace from my deploying to JBoss v3.0 over PostgreSQL 7.1.2:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Load relation failed
Embedded Exception
ERROR: Attribute 'workarea_roles' not found
Can someone tell me what minor detail i'm missing here? I have declared getter/setters on the WorkArea bean only since i only 'CMR' that the Role-side of the relationship (wanting no backward pointing field to retrieve the WorkArea for a Role at this stage). I think i might be missing something to do with my bean declarations but, i can't see what (apologies for not including in mail).
WorkArea(1) -> Role(N). The tables pre-exist complete with foreign key from the role to the work_area table based on the work_area_id (PK of the work_area table).
Here's my DD (relationships section only):
<!-- WorkArea has many Roles -->
<ejb-relation>
<ejb-relation-name>WorkArea-Role</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>workarea-has-roles</ejb-relationship-role-name>
One
<relationship-role-source><ejb-name>WorkArea</ejb-name></relationship-role-source>
<cmr-field>
<cmr-field-name>roles</cmr-field-name>
<cmr-field-type>java.util.Set</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<!-- Role belongs to a Work Area -->
<ejb-relationship-role>
<ejb-relationship-role-name>role-belongs-to-a-workarea</ejb-relationship-role-name>
Many
<relationship-role-source><ejb-name>Role</ejb-name></relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
Here's the jbosscmp-jdbc.xml:
<ejb-relation>
<ejb-relation-name>WorkArea-Role</ejb-relation-name>
<foreign-key-mapping>
<ejb-relationship-role>
<ejb-relationship-role-name>workarea-has-roles</ejb-relationship-role-name>
<foreign-key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>role-belongs-to-a-workarea</ejb-relationship-role-name>
<foreign-key-fields>
<foreign-key-field>
<field-name>workAreaId</field-name>
<column-name>WORK_AREA_ID</column-name>
</foreign-key-field>
</foreign-key-fields>
<!--read-ahead>on-load</read-ahead-->
</ejb-relationship-role>
</foreign-key-mapping>
</ejb-relation>
thanks
Mark