Since each user has only one role, you have a many-to-one association here. Can you get rid of the db_role_user table?
I would simply use:
db_role: ROLE_NANE
db_user: ROLE,NAME,PWD
The user.hbm file would include the following property mapping:
<many-to-one name="role" column="ROLE_ID" class="Role" not-null="true"/>
If you also need to access all users from a single role object (i.e. role.getUsers()), please specify exactly how you plan on doing this, because the required mapping may differ, depending on the way you wish to access the users.
Question you need to answer for yourself: If a role record is removed, what happens to all users with that role?
(p.s. please rate if this was helpful :-) )
|