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.  [ 3 posts ] 
Author Message
 Post subject: A common question on table design and hibernate mapping
PostPosted: Wed Mar 26, 2008 5:57 am 
Newbie

Joined: Wed Nov 15, 2006 8:51 am
Posts: 12
Dear all,

Maybe this is a db design problem.

I have a simple scenario and quite new to ORM concepts. There are 3 tables / entities in my demo app; 1) user, 2) group, 3) accessRule

1 user can have multiple group (ie. 1 to many relationships) and
1 group can have multiple accessRule (ie. 1 to many relationships)

so with my non ORM knowledge, I will create a secondary table to store the keys of the relations between "User" and "Group" ie.
user-group [user_id, group_id]

However, I was wondering if I could use a running number (generated id field) instead of using this approach.

ie. using the key of the secondary table "user-group" (an id field) to reference the "user" and "group" table

Please let me know if there is something wrong in my design (as I feel a bit strange using this approach, and no idea how to do the hibernate mapping config as well)

From Jason (Kusanagihk)


Top
 Profile  
 
 Post subject: Re: A common question on table design and hibernate mapping
PostPosted: Wed Mar 26, 2008 9:38 pm 
Newbie

Joined: Wed Nov 15, 2006 8:51 am
Posts: 12
Could it be a "many-to-many" situation instead???

really confused.

I've found a tutorial similar to my situation
http://www.java2s.com/Code/Java/Hiberna ... ashMap.htm

but it is searchable on only 1 side (ie. in the tutorial's case, only employee is possible to search the benefits; but not possible to search employees from the benefits side)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 9:47 pm 
Beginner
Beginner

Joined: Tue Dec 27, 2005 1:13 pm
Posts: 25
Location: Kingston, ON, Canada
Hi,

For many to many, it should be one user has many groups and one group has many users. Is your case one to many or many to many?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.