-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to map two many-many mapping in a class
PostPosted: Fri Nov 17, 2006 12:30 pm 
Newbie

Joined: Fri Nov 17, 2006 12:16 pm
Posts: 3
Guys,

I have four tables with the following scenario

Table Role
- roleId

Table RoleUACP
- roleUACPId
- roleId
- uacpId

Table UACP
- uacpId
- userId

Table User
- userId

[Role] 1<--->* [RoleUACP] *<--->1 [UACP] *<--->1 [User]

I'm creating a mapping in Role, to get all unique Users belong to each role. But to get to User table, i have to join Role to RoleUACP to UACP, then User. I'm hesitant to create a class definition for RoleUACP and UACP since they're just relationship tables with no business data.

Please let me know how to write a mapping for this situation.

Thanks.

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 10:23 am 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
I'm not sure how to answer your question except that in looking at your tables I don't see why you need both RoleUACP and UACP tables. Can you eliminate one of those? Then it is easy to map.


Top
 Profile  
 
 Post subject: Those are valid tables
PostPosted: Mon Nov 20, 2006 11:10 am 
Newbie

Joined: Fri Nov 17, 2006 12:16 pm
Posts: 3
They are used to implement many to many relationship between role and user

grennis wrote:
I'm not sure how to answer your question except that in looking at your tables I don't see why you need both RoleUACP and UACP tables. Can you eliminate one of those? Then it is easy to map.


Top
 Profile  
 
 Post subject: Those are valid tables
PostPosted: Mon Nov 20, 2006 11:10 am 
Newbie

Joined: Fri Nov 17, 2006 12:16 pm
Posts: 3
They are used to implement many to many relationship between role and user

thanks

grennis wrote:
I'm not sure how to answer your question except that in looking at your tables I don't see why you need both RoleUACP and UACP tables. Can you eliminate one of those? Then it is easy to map.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 11:59 am 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
Many-to-many with role and user does not require 2 intermediate assocation tables, only 1. I still don't see why you need 2.


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