From 99bec968ef4cb392132104f26d5aebe88c532364 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 18 Sep 2024 15:30:35 +0200 Subject: [PATCH] HHH-18632 Concurrency issue with AbstractEntityPersister#nonLazyPropertyLoadPlansByName --- .../persister/entity/AbstractEntityPersister.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 920c839f36..2468c63fd2 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -496,7 +496,7 @@ public abstract class AbstractEntityPersister private final boolean implementsLifecycle; private List uniqueKeyEntries = null; //lazily initialized - private HashMap nonLazyPropertyLoadPlansByName; + private ConcurrentHashMap nonLazyPropertyLoadPlansByName; @Deprecated(since = "6.0") public AbstractEntityPersister( @@ -1671,17 +1671,17 @@ public abstract class AbstractEntityPersister int propertyIndex = getPropertyIndex( fieldName ); partsToSelect.add( getAttributeMapping( propertyIndex ) ); SingleIdArrayLoadPlan lazyLoanPlan; - if ( nonLazyPropertyLoadPlansByName == null ) { - nonLazyPropertyLoadPlansByName = new HashMap<>(); + ConcurrentHashMap propertyLoadPlansByName = this.nonLazyPropertyLoadPlansByName; + if ( propertyLoadPlansByName == null ) { + propertyLoadPlansByName = new ConcurrentHashMap<>(); lazyLoanPlan = createLazyLoanPlan( partsToSelect ); - ; - nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan ); + propertyLoadPlansByName.put( fieldName, lazyLoanPlan ); + this.nonLazyPropertyLoadPlansByName = propertyLoadPlansByName; } else { lazyLoanPlan = nonLazyPropertyLoadPlansByName.get( fieldName ); if ( lazyLoanPlan == null ) { lazyLoanPlan = createLazyLoanPlan( partsToSelect ); - ; nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan ); } }