Reputation: 1414
Uable to achieve aggressive/eager loading at Collection level.
I know eager loading at collection level with XML
but How I could achieve the same with annotation at collection level.?
Student Persistence Class
Here I need to do eager loading for Collection Type semails field.
Upvotes: 0
Views: 601
Reputation: 2561
If you are using hibernate you can use @Fetch
annotation with FetchMode.JOIN. This will make hibernate use join and fetch collection with a single select query joining your element collection table.
Make sure your collection has two annotations:
@ElementCollection(fetch=FetchType.EAGER)
@Fetch(FetchMode.JOIN)
Upvotes: 1
Reputation: 11
You can set the fetch type in the annotation @ElementCollection:
@ElementCollection(fetch=FetchType.EAGER)
Upvotes: 1