File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Many to Many Table Relational Mapping with 3 Tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Many to Many Table Relational Mapping with 3 Tables" Watch "Many to Many Table Relational Mapping with 3 Tables" New topic
Author

Many to Many Table Relational Mapping with 3 Tables

Cloey Tan
Ranch Hand

Joined: Feb 03, 2009
Posts: 60
So far, in EJB3, when it comes to many to many relationship joining 2 tables, we could do something like this


But now i have a situation whereby i need to join 3 tables together, for example I have a User entity, and would need a bridge/join table consisting of 3 keys, userId, roleId, companyId, whereby it links each of them to user's Id, role's Id and company's Id respectively.
So many to many relationship in the above case doesn't seem to work too well for this i assume?
What kind of table relationship mapping should i be using such that i could retrieve a list of role based on a given user Id and company Id?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Moving to EJB.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Many to Many Table Relational Mapping with 3 Tables
 
Similar Threads
ManyToMany Deletes Entries
Meet-in-the-middle mapping question
Need help for Many to Many association
Hibernate I18N Repeated column with composite IDs
Could not determine type for: java.util.Set