Currently, I observe in hbernate3, the following behavior.
if I have
@BatchSize(size=5)
set, then hibernate will fetch 5 subsets of the mapped type in one SQL query.
If I have
.setFetchMode( “set”, FetchMode.JOIN );
, then hibernate will eagerly fetch all the subsets of the mapped type ina single SQL query.
However, when I set
.setFetchMode( “commands”, FetchMode.SELECT );
, then hibernate still uses batch fetching, and not lazy fetching.
Is there a way to force hibernate to use lazy fetching when
@BatchSize
is set?
The same question applies to when
@Fetch(FetchMode.SUBSELECT)
is set.
If you want to override these settings programmatically, you can consider using @FetchProfile.
Just create a @FetchProfile for an entity:
and enable that profile in your service/repository method like:
and your customized fetch settings will work for that session.