If you want to programmatically change these parameters, you can use @FetchProfile. Just create @FetchProfile for the object:
@FetchProfiles({ @FetchProfile(name = "profileName", fetchOverrides = { @FetchProfile.FetchOverride(entity = YourEntity.class, association = "anAssociation", mode = FetchMode.JOIN), ...
}) })
and enable that profile in your service / repository method like:
session.enableFetchProfile( "profileName" );
and your customized fetch settings will work for that session.
source share