From d09237107ebce7fccec59287140289a7db86c151 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Tue, 22 Aug 2023 10:59:11 +0200 Subject: [PATCH] HHH-17045 Use dynamic update when row-id is not available --- .../entity/mutation/UpdateCoordinatorStandard.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java index 3f0c11c309..c476f81a64 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java @@ -302,6 +302,7 @@ protected void performUpdate( inclusionChecker, lockingChecker, dirtinessChecker, + rowId, forceDynamicUpdate, session ); @@ -619,6 +620,7 @@ private UpdateValuesAnalysisImpl analyzeUpdateValues( InclusionChecker inclusionChecker, InclusionChecker lockingChecker, InclusionChecker dirtinessChecker, + Object rowId, boolean forceDynamicUpdate, SharedSessionContractImplementor session) { final AbstractEntityPersister persister = entityPersister(); @@ -635,6 +637,7 @@ private UpdateValuesAnalysisImpl analyzeUpdateValues( oldValues, dirtyAttributeIndexes, dirtinessChecker, + rowId, forceDynamicUpdate ); @@ -1291,6 +1294,7 @@ public UpdateValuesAnalysisImpl( Object[] oldValues, int[] dirtyAttributeIndexes, InclusionChecker dirtinessChecker, + Object rowId, boolean forceDynamicUpdate) { this.values = values; this.dirtyAttributeIndexes = dirtyAttributeIndexes; @@ -1337,6 +1341,9 @@ else if ( dirtyAttributeIndexes != null ) { || entityPersister().optimisticLockStyle() == DIRTY ) { tablesNeedingDynamicUpdate.add( tableMapping ); } + else if ( rowId == null && entityPersister().getRowIdMapping() != null && tableMapping.isIdentifierTable() ) { + tablesNeedingDynamicUpdate.add( tableMapping ); + } } } } ); @@ -1616,6 +1623,7 @@ private MutationOperationGroup buildStaticUpdateGroup() { } }, (index,attribute) -> true, + "", // pass anything here to generate the row id restriction if possible false, null );