I have a simple User/Group relationship.
Tables
[user]
u_id int
name varchar(200)
[group]
g_id int
name varchar(200)
[usr2grp]
u_id int // foreign keys
g_id int // foreign keys
status int2
as u can see the relationtable has some extra column to hold a status value (BLOCKED, NOT_BLOCKED).
I mapped these tables to the following classes/methods.
class User -> table user
class Group -> table group
//collections
User.groups -> simple many-to-many hibernate-mapping with a 'where' "status!=BLOCKED". The collections will never include blocked relations.
Everything is working quite good.
The problem now arises when i try to modfify the status value from the associaten table. fro the faq
http://www.hibernate.org/118.html#A10 i know in this case i have to explictly map the row from that table to a class -e.g UserGroupRelation to be able to access the status value.
But now i have two concepts in my classes.
1. User.groups does not use the explicit relation class
2. UserGroupRelation which is the explicit form
Can i use these two concepts together in my application?
What happens to User.groups when i set the status BLOCKED in a UserGroupRelation object. IMHO hibernate has to reload the
User.groups collection - how can i force this.
Or should i rework my code to only use 1 of these concepts.