Have a look at Hibernate's extra-lazy loading feature.
You enable that by annotating your collection with @LazyCollection(LazyCollectionOption.EXTRA)
. There is this example to look at, and there's Set
used in this one.
public class Users {
@OneToMany(fetch=FetchType.LAZY, mappedBy="users")
@LazyCollection(LazyCollectionOption.EXTRA)
public Set<Sessions> getSessionses() {
return this.sessionses;
}
}