Skip to content

Commit 143ae86

Browse files
committed
HHH-19336 - Proper implementation for JPA extended locking scope
HHH-19459 - LockScope, FollowOnLocking
1 parent 3f661d6 commit 143ae86

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/OracleSqlAstTranslator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected LockStrategy determineLockingStrategy(
169169
if ( followOnStrategy == Locking.FollowOn.DISALLOW ) {
170170
throw new IllegalQueryOperationException( "Locking with set operators is not supported" );
171171
}
172-
else if ( followOnStrategy != Locking.FollowOn.IGNORE ) {
172+
else if ( followOnStrategy == Locking.FollowOn.IGNORE ) {
173173
strategy = LockStrategy.NONE;
174174
}
175175
else {
@@ -181,7 +181,7 @@ else if ( followOnStrategy != Locking.FollowOn.IGNORE ) {
181181
if ( followOnStrategy == Locking.FollowOn.DISALLOW ) {
182182
throw new IllegalQueryOperationException( "Locking with set operators is not supported" );
183183
}
184-
else if ( followOnStrategy != Locking.FollowOn.IGNORE ) {
184+
else if ( followOnStrategy == Locking.FollowOn.IGNORE ) {
185185
strategy = LockStrategy.NONE;
186186
}
187187
else {
@@ -193,7 +193,7 @@ else if ( followOnStrategy != Locking.FollowOn.IGNORE ) {
193193
if ( followOnStrategy == Locking.FollowOn.DISALLOW ) {
194194
throw new IllegalQueryOperationException( "Locking with OFFSET/FETCH is not supported" );
195195
}
196-
else if ( followOnStrategy != Locking.FollowOn.IGNORE ) {
196+
else if ( followOnStrategy == Locking.FollowOn.IGNORE ) {
197197
strategy = LockStrategy.NONE;
198198
}
199199
else {

hibernate-core/src/main/java/org/hibernate/sql/ast/internal/StandardForUpdateClauseStrategy.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
1717
import org.hibernate.metamodel.mapping.internal.BasicValuedCollectionPart;
1818
import org.hibernate.persister.entity.EntityPersister;
19-
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
2019
import org.hibernate.sql.ast.SqlAstJoinType;
2120
import org.hibernate.sql.ast.spi.ForUpdateClauseStrategy;
2221
import org.hibernate.sql.ast.spi.SqlAppender;
@@ -113,9 +112,11 @@ private void trackJoin(TableGroupJoin join) {
113112
@Override
114113
public boolean containsOuterJoins() {
115114
for ( TableGroup tableGroup : rootsToLock ) {
116-
if ( tableGroup.getModelPart() instanceof JoinedSubclassEntityPersister ) {
117-
// inherently has outer joins
118-
return true;
115+
if ( tableGroup.getModelPart() instanceof EntityPersister entityMapping ) {
116+
if ( entityMapping.hasMultipleTables() ) {
117+
// joined inheritance and/or secondary tables - inherently has outer joins
118+
return true;
119+
}
119120
}
120121
}
121122

@@ -129,9 +130,11 @@ public boolean containsOuterJoins() {
129130
&& !joinedGroup.isVirtual() ) {
130131
return true;
131132
}
132-
if ( joinedGroup.getModelPart() instanceof JoinedSubclassEntityPersister ) {
133-
// inherently has outer joins
134-
return true;
133+
if ( joinedGroup.getModelPart() instanceof EntityPersister entityMapping ) {
134+
if ( entityMapping.hasMultipleTables() ) {
135+
// joined inheritance and/or secondary tables - inherently has outer joins
136+
return true;
137+
}
135138
}
136139
}
137140

0 commit comments

Comments
 (0)