use of org.hibernate.loader.ast.spi.CascadingFetchProfile in project hibernate-orm by hibernate.
the class SingleIdEntityLoaderStandardImpl method resolveLoadPlan.
@Internal
public SingleIdLoadPlan<T> resolveLoadPlan(LockOptions lockOptions, LoadQueryInfluencers loadQueryInfluencers, SessionFactoryImplementor sessionFactory) {
if (getLoadable().isAffectedByEnabledFilters(loadQueryInfluencers)) {
// special case of not-cacheable based on enabled filters effecting this load.
//
// This case is special because the filters need to be applied in order to
// properly restrict the SQL/JDBC results. For this reason it has higher
// precedence than even "internal" fetch profiles.
nonReusablePlansGenerated.incrementAndGet();
return createLoadPlan(lockOptions, loadQueryInfluencers, sessionFactory);
}
final CascadingFetchProfile enabledCascadingFetchProfile = loadQueryInfluencers.getEnabledCascadingFetchProfile();
if (enabledCascadingFetchProfile != null) {
if (LockMode.UPGRADE.greaterThan(lockOptions.getLockMode())) {
if (selectByInternalCascadeProfile == null) {
selectByInternalCascadeProfile = new EnumMap<>(CascadingFetchProfile.class);
} else {
final SingleIdLoadPlan existing = selectByInternalCascadeProfile.get(enabledCascadingFetchProfile);
if (existing != null) {
// noinspection unchecked
return existing;
}
}
final SingleIdLoadPlan<T> plan = createLoadPlan(lockOptions, loadQueryInfluencers, sessionFactory);
selectByInternalCascadeProfile.put(enabledCascadingFetchProfile, plan);
return plan;
}
}
// otherwise see if the loader for the requested load can be cached - which
// also means we should look in the cache for an existing one
final boolean reusable = determineIfReusable(lockOptions, loadQueryInfluencers);
if (reusable) {
final SingleIdLoadPlan existing = selectByLockMode.get(lockOptions.getLockMode());
if (existing != null) {
// noinspection unchecked
return existing;
}
final SingleIdLoadPlan<T> plan = createLoadPlan(lockOptions, loadQueryInfluencers, sessionFactory);
selectByLockMode.put(lockOptions.getLockMode(), plan);
return plan;
}
nonReusablePlansGenerated.incrementAndGet();
return createLoadPlan(lockOptions, loadQueryInfluencers, sessionFactory);
}
use of org.hibernate.loader.ast.spi.CascadingFetchProfile in project hibernate-orm by hibernate.
the class LoadQueryInfluencers method fromInternalFetchProfile.
// internal fetch profile support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public <T> T fromInternalFetchProfile(CascadingFetchProfile profile, Supplier<T> supplier) {
final CascadingFetchProfile previous = this.enabledCascadingFetchProfile;
this.enabledCascadingFetchProfile = profile;
try {
return supplier.get();
} finally {
this.enabledCascadingFetchProfile = previous;
}
}
Aggregations