-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Best Strategy for Mapping User and Roles?
PostPosted: Sun Feb 08, 2009 7:25 pm 
Beginner
Beginner

Joined: Sat Feb 07, 2009 4:08 pm
Posts: 22
Location: New York City
I am confused about how I should be thinking about this very basic association: A USER table and a ROLE table. Obviously, each user has many roles. The USER is obviously an Entity class, but the ROLES table I think should be a static table that is loaded from a file because it will never change and the ID column needs to be fixed...so this makes me believe that there should not be a ROLE entity.

What is the proper way to think about this?

And if I do use a static table for roles, how do I incorporate static tables using Hibernate? If I use hbm2ddl to export my schema, how do I deal with static tables?

Thanks for any help you can give to clarify my thinking on this!

John


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 3:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
If you want to use a table in Hibernate you need to map it to an entity. You can make it almost read-only if you set <class ... mutable="false" ... />.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 6:53 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Quote:
so this makes me believe that there should not be a ROLE entity.

Role will be an entity only coz it has its own properties and existence. Only thing is that once initialized, you wont be making any updations to the role table. So for the mapping part you will map it like any other table.


Quote:
If I use hbm2ddl to export my schema, how do I deal with static tables?

Well hbm2dll will only handle the creation of the table. Population of the data should be handled by your application code. Probably you can do this in ur application initialization code.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.