Hello,
I need a solution to insert an element to a Collection without loading the whole elements of that Collection before inserting.
With a ManyToMany relation between UserGroups and Roles given, i want to add a Role to a UserGroup like usergroup.getRoles().add(role). However, Hibernate initializes the Collection before adding the element (
reason).
A solution ought to be using a Bag instead of a List/Set.
How do I accomplish that? Do I use a secret @Bag Annotation or should I use the org.hibernate.mapping.Bag class as the member-type of the Collection? I couldn't find any examples for that so I would be glad to see some (using annotations).