Bag 2 « Map « JPA Q&A





2. Using Bags for performance adding in Collections    forum.hibernate.org

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 ...

3. @ManyToOne x 2 = "cannot fetch simultaneous bags"    forum.hibernate.org

Hi all, I know that one has to use Set or annotations when a JPA entity has two or more collections or @OneToMany relationships to get the collections to populate on eager loading. However I am getting this error on one of my entities that has two @ManyToOne relationships. It has worked without problems for hundreds of other entity classes that ...

4. Bag or set? which one is the best?    forum.hibernate.org

Hi there, I've been using bags for a while, but recently I make use of sets. I've seen some differences but I really would like to hear the advice from an expert: which one is best, bag or set? performance, scalability, etc.? I know that when using sets I must implement equals and hashcode, which leads to the "object id vs ...