wood burning stoves*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 19684
    
  20

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