Skip to content

Commit

Permalink
HHH-14305 Memory optimisations for AbstractEntityPersister#uniqueKeyL…
Browse files Browse the repository at this point in the history
…oaders
  • Loading branch information
Sanne committed Nov 1, 2020
1 parent d6108fa commit bc0f3d9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ public abstract class AbstractEntityPersister

private volatile Set<String> affectingFetchProfileNames;

private final Map uniqueKeyLoaders = new HashMap();

private final LockModeEnumMap<LockingStrategy> lockers = new LockModeEnumMap<>();

private final EntityLoaderLazyCollection loaders = new EntityLoaderLazyCollection();

private volatile Map<String,EntityLoader> uniqueKeyLoaders;

// SQL strings
private String sqlVersionSelectString;
private String sqlSnapshotSelectString;
Expand Down Expand Up @@ -2433,7 +2433,8 @@ private EntityLoader getAppropriateUniqueKeyLoader(String propertyName, SharedSe
&& propertyName.indexOf( '.' ) < 0; //ugly little workaround for fact that createUniqueKeyLoaders() does not handle component properties

if ( useStaticLoader ) {
return (EntityLoader) uniqueKeyLoaders.get( propertyName );
final Map<String, EntityLoader> uniqueKeyLoaders = this.uniqueKeyLoaders;
return uniqueKeyLoaders == null ? null : uniqueKeyLoaders.get( propertyName );
}
else {
return createUniqueKeyLoader(
Expand All @@ -2453,6 +2454,9 @@ protected void createUniqueKeyLoaders() throws MappingException {
String[] propertyNames = getPropertyNames();
for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
if ( propertyUniqueness[i] ) {
if ( uniqueKeyLoaders == null ) {
this.uniqueKeyLoaders = new HashMap<>();
}
//don't need filters for the static loaders
uniqueKeyLoaders.put(
propertyNames[i],
Expand Down

0 comments on commit bc0f3d9

Please sign in to comment.