-->
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.  [ 2 posts ] 
Author Message
 Post subject: Associating data with join table
PostPosted: Tue Jan 03, 2006 10:35 am 
Newbie

Joined: Tue Jan 03, 2006 10:19 am
Posts: 1
Working on a retrofit of an existing Toplink-based project to Hibernate. The data model requires some data to be associated with a join, and the only way I've been able to make it all work is to specify the join table as a domain object and manage it directly, which is sort of ugly.

Role has 1-many to UserRoleAssociation has many-1 to User (Role has many-many to User)
UserRoleAssociation currently has the Role and User ids plus a one-many relationship to a CustomData class

Is there a way to deal with this situation in Hibernate and preserve the ability to ask the User for his Roles and vice-versa, rather than having to query the association table as I'm doing currently?


Top
 Profile  
 
 Post subject: look at join table tag
PostPosted: Wed Jan 04, 2006 1:47 pm 
Newbie

Joined: Mon Nov 07, 2005 6:11 pm
Posts: 6
Seems to me you could have mappings for User and Role, and in each mapping use a <join table> mapping to relate the one to the other via the UserRole table. See the hibernate documentation for how to do this:

http://www.hibernate.org/hib_docs/v3/re ... ional-join

jh


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

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.