GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes [Hibernate] Many-to-many with non-changing data on one side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "[Hibernate] Many-to-many with non-changing data on one side" Watch "[Hibernate] Many-to-many with non-changing data on one side" New topic
Author

[Hibernate] Many-to-many with non-changing data on one side

Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
Hello

What would be the best way to map the following many-to-many situation?

I want to map User (userId, username, password, firstname, lastname, roles)

to

Role (roleId, name)

A role is really just a name and the system contains 4 roles (admin, user, etc). Each User can have one or more roles, and each Role can be assigned to one or more Users. These roles never change, so what I need in the database is a USER table with user data and a ROLE table with just 4 records that never change and an association table between them.

Is there a way to specify the roles in a HBM mapping, kinda like an Enum?

OMG. The Netherlands is playing against Brazil, so thanks in advance for your responses, I'll read them in a couple of hours.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Hibernate] Many-to-many with non-changing data on one side