Skip to content

Commit

Permalink
HHH-14305 Memory optimisation for AbstractEntityPersister#affectingFe…
Browse files Browse the repository at this point in the history
…tchProfileNames
  • Loading branch information
Sanne committed Nov 1, 2020
1 parent c7f87b0 commit b927de9
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public abstract class AbstractEntityPersister
// dynamic filters attached to the class-level
private final FilterHelper filterHelper;

private final Set<String> affectingFetchProfileNames = new HashSet<>();
private volatile Set<String> affectingFetchProfileNames;

private final Map uniqueKeyLoaders = new HashMap();

Expand Down Expand Up @@ -4466,6 +4466,9 @@ public List multiLoad(Serializable[] ids, SharedSessionContractImplementor sessi
}

public void registerAffectingFetchProfile(String fetchProfileName) {
if ( affectingFetchProfileNames == null ) {
this.affectingFetchProfileNames = new HashSet<>();
}
affectingFetchProfileNames.add( fetchProfileName );
}

Expand All @@ -4474,9 +4477,12 @@ private boolean isAffectedByEntityGraph(SharedSessionContractImplementor session
}

private boolean isAffectedByEnabledFetchProfiles(SharedSessionContractImplementor session) {
for ( String s : session.getLoadQueryInfluencers().getEnabledFetchProfileNames() ) {
if ( affectingFetchProfileNames.contains( s ) ) {
return true;
final Set<String> fetchProfileNames = this.affectingFetchProfileNames;
if ( fetchProfileNames != null ) {
for ( String s : session.getLoadQueryInfluencers().getEnabledFetchProfileNames() ) {
if ( fetchProfileNames.contains( s ) ) {
return true;
}
}
}
return false;
Expand Down

0 comments on commit b927de9

Please sign in to comment.