[jboss-user] [Beginner's Corner] - Re: ManyToMany problem
do-not-reply at jboss.com
Thu Oct 29 11:53:24 EDT 2009
I assume that you want to use EJB3/JPA for creating your entities?
In this case, you don't need a role_function entity, and the server will autogenerate the database table for you. The entity "Role" will have a list of "Functions", and the "Function" will have a list of "Role", both connected by annotations.
| public class Role implements Serializable
| @ManyToMany (mappedBy="roles")
| public List<Function> functions;
| public class Function implements Serializable
| @ManyToMany ()
| public List<Role> roles;
Then, your code can access the functions of a role by "myRole.functions.get(x);". The rest is the job of the server and you don't have to care much about it.
Of course, there is quite a bit more to keep in mind. First of all, the two fields should have a getter and setter. More detailed information can be found here: http://www.jboss.org/community/wiki/EJB3relationships
Hope this helps
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263012#4263012
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263012
More information about the jboss-user