Seam Framework - ManyToMany relationship in JPA using join table example
• Maniezhilan shanmugam
In my recent project i have to create a user who can be assigned multiple roles. The class structure looks as follows.
In my UserAccount class the @ManyToMany relationship looks like as follows,
In SiteRole class the @ManyToMany relationship looks like as follows,
In the UserRole (mapped to join table) attributes are as follows,
The UserRolePK class attributes are as follows
The UserRolePK class is needed as the UserRole table has composite key ( remember ?? the ejb days writing the PKClass).Hmm..the title goes like Seam Framework …., what seam has anything to do with this?Well seam makes the user creation with multiple roles easy using seam tags like selectManyCheckboxes as explained here.Moreover jpaidentitystore in seam framework helps in declaring the user-class and role-class inside of components class as explained here.