-->
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.  [ 1 post ] 
Author Message
 Post subject: One-to-many on a basic class
PostPosted: Mon Jul 27, 2009 6:30 pm 
Newbie

Joined: Thu Jul 23, 2009 11:48 am
Posts: 9
I'm trying to figure out how to set up a one-to-many relationship on an Integer class. I have a User object that has a Set of "roles" which define the user's permissions, like this:
Code:
public class User {
  Set roles;
}

The roles are just plain Integers, i.e. 1 = USER and 2 = ADMIN. I'm trying to set up a one-to-many relationship between the User and roles, like this:
Code:
<class name="BasicUser" table="users">
  ...
  <set name="roles" table="user_roles">
     <key column="user_id"/>
     <one-to-many ???? />
  </set>
</class>   

However, I can't figure out what attributes I should put in the one-to-many tag. All of the examples I find for one-to-many use the "class" attribute, but it seems that would require a mapping for the Integer class to the USER_ROLES table. Is there a way I can tell one-to-many which column to look for without having to create a new class mapping?


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

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.