Being quite new to Hibernate, I want to get some help on the concept of many-to-many associations and how to retrieve the HashSet.
If I have a many-to-many association between a User and a Role, how can I retrieve the HashSet of Roles of a specific User?
In User, I have
Code:
private Set roles = new HashSet();
And to get it I perform
Code:
java.util.Set set = userSacado.getRoles();
But if I try to
Code:
(HashSet)set;
it, it will give the exception
Code:
java.lang.ClassCastException: org.hibernate.collection.PersistentSet
Can anyone help me out on these concepts of (un)initialized collections and how can I get the HashSet (and its contents) available after I close the session, in my business and web tier of the application?