Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Many to Many Table Relational Mapping with 3 Tables

 
Cloey Tan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to EJB.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic