I have a class called SynonymMapping which has a collection of values mapped as a CollectionOfElements
@Entity(name = \"synonymmapping\")
public class Synony
I stepped into the same problem - when you set the FetchType.EAGER for a @CollectionOfElements, the Hibernate tries to get everything in one shot, i.e. using one single query for each entry of element linked to a "master" object. This problem can be successfully solved at a cost of N+1 query, if you add the @Fetch (FetchMode.SELECT) annotation to your collection. In my case I wanted to have a MediaObject entity with a collection of its metadata items (video codec, audio codec, sizes, etc.). The mapping for a metadataItems collection looks as follows:
@CollectionOfElements (targetElement = String.class, fetch = FetchType.EAGER) @JoinTable(name = "mo_metadata_item", joinColumns = @JoinColumn(name = "media_object_id")) @MapKey(columns = @Column(name = "name")) @Column (name = "value") @Fetch (FetchMode.SELECT) private MapmetadataItems = new HashMap ();