After reading your post (I had the same problem) I tried every descendant of
java.util.Collection. It worked only with java.util:collection itself.
the nice thing is that without specifying anything, JBoss created a link table between the
two entities. Which is what should be done.
example:
/**
* @return the roles
*/
@ManyToMany(
targetEntity=Role.class,
cascade={CascadeType.PERSIST, CascadeType.MERGE}
)
public Collection < Role > getRoles() {
if(roles == null) {
roles = new LinkedList < Role >();
}
return roles;
}
/**
* this setter must exist for hibernate but be private because we don't want anyone
to use it
* @param roles the roles to set
*/
@SuppressWarnings("unused")
private void setRoles(Collection < Role > roles) {
this.roles = roles;
}
When the Roles are read from the database, the Class used for the roles Collection is
org.hibernate.collection.PersistentBag
It would actually be nice to be able to choose a type that disallows duplicates in the
list. Because now I have to catch the exception upon "persist".
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128070#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...