Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Many to Many Table Relational Mapping with 3 Tables

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?
Posts: 22017
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to EJB.
it's a teeny, tiny, wafer thin ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic