You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Ge...@lex-com.net on 2003/08/13 12:19:23 UTC
Problem with anonymous keys in 1:n back-mapping
Hi all,
I tried to implement a bi-directional 1:n association between classes User
and UserRole with an anonymous key in UserRole:
<class-descriptor
class="de.lexcom.noralinkojb.model.User"
table="OJB.USERS">
<field-descriptor
name="id"
column="ID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<collection-descriptor
name="roles"
element-class-ref="de.lexcom.noralinkojb.model.UserRole"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="userId"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="de.lexcom.noralinkojb.model.UserRole"
table="OJB.USER_ROLES">
<field-descriptor
name="userId"
column="USER_ID"
jdbc-type="INTEGER"
primarykey="true"
access="anonymous"/>
<field-descriptor
name="role"
column="ROLE"
jdbc-type="INTEGER"
primarykey="true"/>
<reference-descriptor
name="user"
class-ref="de.lexcom.noralinkojb.model.User"
auto-retrieve="true">
<foreignkey field-ref="userId"/>
</reference-descriptor>
</class-descriptor>
When I now load a User object which has associated UserRoles, the user
attribute of all UserRoles is null. The problem disappears when I make
userId a normal attribute of UserRole.
Is this a known limitation of anonymous keys, is it a bug or am I doing
something wrong here?
Regards,
Gerhard