Hi all,
i have several DB tables to represent a role-based-access-model.
One table contains the roles users may have, whereby a role may have a parent role. So the table looks like this:
role_id (PK) | role_name | parent_role_id
when
role_id and
parent_role_id equals, this should indicate that a role has no parent role (parent_role_id can't be null because it's an int in DB).
Hibernate will now reference parent-role to the role object itself (role == parentRole), when
role_id and
parent_role_id in DB equals.
How can i configure a mapping that doesn't set the parent-role (keeps it null) in the case described above?
Here is my existing mapping:
Code:
<class name="Role" table="ROLE" lazy="false">
<id name="roleID" type="integer">
<column name="ROLE_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="parentRole" class="Role" fetch="select"
lazy="false">
<column name="PARENT_ROLE_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
...
</class>
thanks for advice