Skip to content

Commit 0cea4d3

Browse files
committed
HHH-18632 Concurrency issue with AbstractEntityPersister#nonLazyPropertyLoadPlansByName
1 parent 4fbc8f9 commit 0cea4d3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public abstract class AbstractEntityPersister
464464
private final boolean implementsLifecycle;
465465

466466
private List<UniqueKeyEntry> uniqueKeyEntries = null; //lazily initialized
467-
private HashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
467+
private ConcurrentHashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
468468

469469
public AbstractEntityPersister(
470470
final PersistentClass persistentClass,
@@ -1552,17 +1552,17 @@ protected Object initializeLazyPropertiesFromDatastore(
15521552
int propertyIndex = getPropertyIndex( fieldName );
15531553
partsToSelect.add( getAttributeMapping( propertyIndex ) );
15541554
SingleIdArrayLoadPlan lazyLoanPlan;
1555-
if ( nonLazyPropertyLoadPlansByName == null ) {
1556-
nonLazyPropertyLoadPlansByName = new HashMap<>();
1555+
ConcurrentHashMap<String, SingleIdArrayLoadPlan> propertyLoadPlansByName = this.nonLazyPropertyLoadPlansByName;
1556+
if ( propertyLoadPlansByName == null ) {
1557+
propertyLoadPlansByName = new ConcurrentHashMap<>();
15571558
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1558-
;
1559-
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1559+
propertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1560+
this.nonLazyPropertyLoadPlansByName = propertyLoadPlansByName;
15601561
}
15611562
else {
15621563
lazyLoanPlan = nonLazyPropertyLoadPlansByName.get( fieldName );
15631564
if ( lazyLoanPlan == null ) {
15641565
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1565-
;
15661566
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
15671567
}
15681568
}

0 commit comments

Comments
 (0)