Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public EffectiveEntityGraph(boolean allowOverwrite) {
* @throws IllegalArgumentException Thrown if the semantic is null
* @throws IllegalStateException If previous state is still available (hasn't been cleared).
*/
public void applyGraph(RootGraphImplementor<?> graph, @Nullable GraphSemantic semantic) {
public void applyGraph(RootGraphImplementor<?> graph, GraphSemantic semantic) {
if ( semantic == null ) {
throw new IllegalArgumentException( "Graph semantic cannot be null" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public LoadQueryInfluencers(SessionFactoryImplementor sessionFactory, SessionCre
}
}

public EffectiveEntityGraph applyEntityGraph(@Nullable RootGraphImplementor<?> rootGraph, @Nullable GraphSemantic graphSemantic) {
public EffectiveEntityGraph applyEntityGraph(RootGraphImplementor<?> rootGraph, GraphSemantic graphSemantic) {
final var effectiveEntityGraph = getEffectiveEntityGraph();
if ( graphSemantic != null ) {
if ( rootGraph == null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.hibernate.RemovalsMode;
import org.hibernate.SessionCheckMode;
import org.hibernate.UnknownProfileException;
import org.hibernate.engine.spi.EffectiveEntityGraph;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.graph.GraphSemantic;
Expand Down Expand Up @@ -170,7 +168,7 @@ public <K> List<T> multiLoad(K... ids) {
}

public List<T> perform(Supplier<List<T>> executor) {
final CacheMode sessionCacheMode = session.getCacheMode();
final var sessionCacheMode = session.getCacheMode();
boolean cacheModeChanged = false;
if ( cacheMode != null ) {
// naive check for now...
Expand All @@ -182,16 +180,20 @@ public List<T> perform(Supplier<List<T>> executor) {
}

try {
final LoadQueryInfluencers influencers = session.getLoadQueryInfluencers();
final HashSet<String> fetchProfiles =
final var influencers = session.getLoadQueryInfluencers();
final var fetchProfiles =
influencers.adjustFetchProfiles( disabledFetchProfiles, enabledFetchProfiles );
final EffectiveEntityGraph effectiveEntityGraph =
influencers.applyEntityGraph( rootGraph, graphSemantic );
final var effectiveEntityGraph =
rootGraph == null
? null
: influencers.applyEntityGraph( rootGraph, graphSemantic );
try {
return executor.get();
}
finally {
effectiveEntityGraph.clear();
if ( effectiveEntityGraph != null ) {
effectiveEntityGraph.clear();
}
influencers.setEnabledFetchProfileNames( fetchProfiles );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.hibernate.NaturalIdMultiLoadAccess;
import org.hibernate.OrderingMode;
import org.hibernate.RemovalsMode;
import org.hibernate.engine.spi.EffectiveEntityGraph;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.spi.RootGraphImplementor;
Expand Down Expand Up @@ -121,12 +119,12 @@ public List<T> multiLoad(Object... ids) {
}
}

final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
final var loadQueryInfluencers = session.getLoadQueryInfluencers();

try {
final EffectiveEntityGraph effectiveEntityGraph = loadQueryInfluencers.getEffectiveEntityGraph();
final GraphSemantic initialGraphSemantic = effectiveEntityGraph.getSemantic();
final RootGraphImplementor<?> initialGraph = effectiveEntityGraph.getGraph();
final var effectiveEntityGraph = loadQueryInfluencers.getEffectiveEntityGraph();
final var initialGraphSemantic = effectiveEntityGraph.getSemantic();
final var initialGraph = effectiveEntityGraph.getGraph();
final boolean hadInitialGraph = initialGraphSemantic != null;

if ( graphSemantic != null ) {
Expand All @@ -137,7 +135,9 @@ public List<T> multiLoad(Object... ids) {
}

try {
return (List<T>) entityDescriptor.getMultiNaturalIdLoader().multiLoad( ids, this, session );
return (List<T>)
entityDescriptor.getMultiNaturalIdLoader()
.multiLoad( ids, this, session );
}
finally {
if ( graphSemantic != null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,21 @@ protected final T doLoad(Object normalizedNaturalIdValue) {
final var session = context.getSession();
final var influencers = session.getLoadQueryInfluencers();
final var fetchProfiles = influencers.adjustFetchProfiles( disabledFetchProfiles, enabledFetchProfiles );
final var effectiveEntityGraph = influencers.applyEntityGraph( rootGraph, graphSemantic );
final var effectiveEntityGraph =
rootGraph == null
? null
: influencers.applyEntityGraph( rootGraph, graphSemantic );
try {
@SuppressWarnings("unchecked")
final T loaded = cachedResolution != null
? identifierLoadAccess().load(cachedResolution)
? identifierLoadAccess().load( cachedResolution )
: (T) entityPersister().getNaturalIdLoader()
.load( normalizedNaturalIdValue, this, session );
if ( loaded != null ) {
final var persistenceContext = session.getPersistenceContextInternal();
final var lazyInitializer = HibernateProxy.extractLazyInitializer( loaded );
final var entry = lazyInitializer != null
? persistenceContext.getEntry( lazyInitializer.getImplementation() )
: persistenceContext.getEntry( loaded );
final var entity = lazyInitializer != null ? lazyInitializer.getImplementation() : loaded;
final var entry = persistenceContext.getEntry( entity );
assert entry != null;
if ( entry.getStatus() == Status.DELETED ) {
return null;
Expand All @@ -196,7 +198,9 @@ protected final T doLoad(Object normalizedNaturalIdValue) {
}
finally {
context.delayedAfterCompletion();
effectiveEntityGraph.clear();
if ( effectiveEntityGraph != null ) {
effectiveEntityGraph.clear();
}
influencers.setEnabledFetchProfileNames( fetchProfiles );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@ protected T perform(Supplier<T> executor) {
try {
final var influencers = session.getLoadQueryInfluencers();
final var fetchProfiles = influencers.adjustFetchProfiles( disabledFetchProfiles, enabledFetchProfiles );
final var effectiveEntityGraph = influencers.applyEntityGraph( rootGraph, graphSemantic);
final var effectiveEntityGraph =
rootGraph == null
? null
: influencers.applyEntityGraph( rootGraph, graphSemantic);
try {
return executor.get();
}
finally {
effectiveEntityGraph.clear();
if ( effectiveEntityGraph != null ) {
effectiveEntityGraph.clear();
}
influencers.setEnabledFetchProfileNames( fetchProfiles );
}
}
Expand Down
Loading