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: ManytoMany with persistent attributes
PostPosted: Sat Jan 01, 2011 1:41 pm 
Newbie

Joined: Sat Jan 01, 2011 12:48 pm
Posts: 1
Location: Brazil - Pernambuco - Petrolina
Hi,

I'm trying to do a many to many relationship, however, my table has some persistent attributes.

Users (* id, name, login, password);
Roles (* id, description);
Permissions (* iduser, * idrole, candelete, canmodify, canupdate);

I wish to use Hibernate Annotations and I haven't find another way to do this except to create Permissions like a persistent class and set a Collection property to the User's persistent class.

Code:
public class User
{
       public int id;
       public String name;
       public String login;
       public String Password;
       public List<Permission> Permissions;
}

public class Role
{
      public int id;
      public String Description;
}

public class Permission
{
      public Role Role;
      public Boolean CanModify;
      public Boolean CanUpdate;
      public Boolean CanDelete;
}


My Questions are:
How can I do this mapping?
There another way to do this with @ManyToMany Annotation?

thankful for any help

_________________
João Dias de Carvalho Neto
Software Developer
Brazil - Pernambuco - Petrolina


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.