-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: explicit association table repres. vs. common m2m mapping
PostPosted: Thu Nov 23, 2006 4:40 am 
Newbie

Joined: Wed Nov 15, 2006 7:38 am
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.