Hibernate 3.1
Folks,
I have mapped User<->Role, many-to-many, this way:
<hibernate-mapping
>
<class
name="User"
table="USER"
...
<set
name="roles"
table="USER_ROLE"
>
<key column="user_id" />
<many-to-many class="Role" column="role_id"/>
</set>
<hibernate-mapping
>
<class
name="Role"
table="ROLE"
mutable="true"
>
...
<set
name="users"
table="USER_ROLE"
inverse="true"
>
<key column="role_id" />
<many-to-many class="User" column="user_id"/>
</set>
Everything works as advertised. But there are attributes (properties) on the join table USER_ROLE (for legacy reasons). I need to be able to set a couple of these attributes (columns) on the USER_ROLE table each time Hibernate does an implicit insert as a result of my manipulating the many-to-many relationship. The values I need to insert are *constants*. I do not ever need to read these attributes.
Is there some way to do this without having to model the join table (USER_ROLE) as an entity? I prefer the streamlined model of having the join table completely hidden from my java model classes.
Thanks for any pointers.
Joe
|