Skip to content

Commit 54e6623

Browse files
committed
HHH-19551 - Address deficiencies in pessimistic locking
1 parent 818df6d commit 54e6623

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+704
-148
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
db=h2
1+
db=mssql_ci
22

33
# Keep all these properties in sync unless you know what you are doing!
44
# We set '-Dlog4j2.disableJmx=true' to prevent classloader leaks triggered by the logger.

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/AltibaseDialect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.hibernate.dialect.OracleDialect;
2626
import org.hibernate.dialect.function.CommonFunctionFactory;
2727
import org.hibernate.dialect.function.OracleTruncFunction;
28-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
28+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
2929
import org.hibernate.dialect.pagination.LimitHandler;
3030
import org.hibernate.dialect.sequence.SequenceSupport;
3131
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
@@ -586,9 +586,9 @@ public boolean supportsFromClauseInUpdate() {
586586
}
587587

588588
@Override
589-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
589+
public OuterJoinLockingType getOuterJoinLockingType() {
590590
// "SELECT FOR UPDATE can only be used with a single-table SELECT statement"
591-
return OuterJoinLockingLevel.UNSUPPORTED;
591+
return OuterJoinLockingType.UNSUPPORTED;
592592
}
593593

594594
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CacheDialect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.hibernate.dialect.lock.LockingStrategy;
2222
import org.hibernate.dialect.lock.PessimisticReadUpdateLockingStrategy;
2323
import org.hibernate.dialect.lock.PessimisticWriteUpdateLockingStrategy;
24-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
24+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
2525
import org.hibernate.dialect.pagination.LimitHandler;
2626
import org.hibernate.dialect.pagination.TopLimitHandler;
2727
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -315,9 +315,9 @@ public LockingClauseStrategy getLockingClauseStrategy(QuerySpec querySpec, LockO
315315
}
316316

317317
@Override
318-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
318+
public OuterJoinLockingType getOuterJoinLockingType() {
319319
// InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax at all
320-
return OuterJoinLockingLevel.UNSUPPORTED;
320+
return OuterJoinLockingType.UNSUPPORTED;
321321
}
322322

323323
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacyDialect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.hibernate.dialect.function.PostgreSQLTruncFunction;
3535
import org.hibernate.dialect.identity.CockroachDBIdentityColumnSupport;
3636
import org.hibernate.dialect.identity.IdentityColumnSupport;
37-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
37+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
3838
import org.hibernate.dialect.pagination.LimitHandler;
3939
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
4040
import org.hibernate.dialect.sequence.PostgreSQLSequenceSupport;
@@ -1085,8 +1085,8 @@ public String getForUpdateSkipLockedString(String aliases) {
10851085
}
10861086

10871087
@Override
1088-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
1089-
return OuterJoinLockingLevel.UNSUPPORTED;
1088+
public OuterJoinLockingType getOuterJoinLockingType() {
1089+
return OuterJoinLockingType.UNSUPPORTED;
10901090
}
10911091

10921092
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
import org.hibernate.dialect.function.TrimFunction;
2828
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
2929
import org.hibernate.dialect.identity.IdentityColumnSupport;
30-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
30+
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
31+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
3132
import org.hibernate.dialect.pagination.DB2LimitHandler;
3233
import org.hibernate.dialect.pagination.LegacyDB2LimitHandler;
3334
import org.hibernate.dialect.pagination.LimitHandler;
@@ -811,8 +812,8 @@ public String getReadLockString(int timeout) {
811812
}
812813

813814
@Override
814-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
815-
return OuterJoinLockingLevel.UNSUPPORTED;
815+
public OuterJoinLockingType getOuterJoinLockingType() {
816+
return OuterJoinLockingType.UNSUPPORTED;
816817
}
817818

818819
@Override
@@ -821,9 +822,9 @@ public boolean supportsExistsInSelect() {
821822
}
822823

823824
@Override
824-
public boolean supportsLockTimeouts() {
825+
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
825826
//as far as I know, DB2 doesn't support this
826-
return false;
827+
return LockTimeoutStyle.NONE;
827828
}
828829

829830
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DerbyDialect.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
3131
import org.hibernate.dialect.identity.IdentityColumnSupport;
3232
import org.hibernate.community.dialect.pagination.DerbyLimitHandler;
33-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
33+
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
34+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
3435
import org.hibernate.dialect.pagination.LimitHandler;
3536
import org.hibernate.community.dialect.sequence.DerbySequenceSupport;
3637
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -608,9 +609,9 @@ public String getReadLockString(int timeout) {
608609
}
609610

610611
@Override
611-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
612+
public OuterJoinLockingType getOuterJoinLockingType() {
612613
//TODO: check this!
613-
return OuterJoinLockingLevel.UNSUPPORTED;
614+
return OuterJoinLockingType.UNSUPPORTED;
614615
}
615616

616617
@Override
@@ -620,10 +621,11 @@ public boolean supportsExistsInSelect() {
620621
}
621622

622623
@Override
623-
public boolean supportsLockTimeouts() {
624+
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
624625
// To enable the lock timeout, we need a dedicated call
625626
// 'call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.locks.waitTimeout', '3')'
626-
return false;
627+
// Even supporting that at the CONNECTION level would be tough
628+
return LockTimeoutStyle.NONE;
627629
}
628630

629631
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DerbyLegacyDialect.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
import org.hibernate.dialect.function.InsertSubstringOverlayEmulation;
2929
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
3030
import org.hibernate.dialect.identity.IdentityColumnSupport;
31-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
31+
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
32+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
3233
import org.hibernate.dialect.pagination.AbstractLimitHandler;
3334
import org.hibernate.community.dialect.pagination.DerbyLimitHandler;
3435
import org.hibernate.dialect.pagination.LimitHandler;
@@ -614,9 +615,9 @@ public String getReadLockString(int timeout) {
614615
}
615616

616617
@Override
617-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
618+
public OuterJoinLockingType getOuterJoinLockingType() {
618619
//TODO: check this!
619-
return OuterJoinLockingLevel.UNSUPPORTED;
620+
return OuterJoinLockingType.UNSUPPORTED;
620621
}
621622

622623
@Override
@@ -626,10 +627,11 @@ public boolean supportsExistsInSelect() {
626627
}
627628

628629
@Override
629-
public boolean supportsLockTimeouts() {
630+
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
630631
// To enable the lock timeout, we need a dedicated call
631632
// 'call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.locks.waitTimeout', '3')'
632-
return false;
633+
// Even supporting that at the CONNECTION level would be tough
634+
return LockTimeoutStyle.NONE;
633635
}
634636

635637
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdDialect.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.regex.Matcher;
2222
import java.util.regex.Pattern;
2323

24+
import jakarta.persistence.Timeout;
2425
import org.hibernate.boot.Metadata;
2526
import org.hibernate.boot.model.FunctionContributions;
2627
import org.hibernate.boot.model.TypeContributions;
@@ -37,7 +38,8 @@
3738
import org.hibernate.dialect.TimeZoneSupport;
3839
import org.hibernate.dialect.function.CommonFunctionFactory;
3940
import org.hibernate.dialect.identity.IdentityColumnSupport;
40-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
41+
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
42+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
4143
import org.hibernate.dialect.pagination.LimitHandler;
4244
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
4345
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -692,16 +694,17 @@ public String getSelectGUIDString() {
692694
}
693695

694696
@Override
695-
public boolean supportsLockTimeouts() {
696-
// Lock timeouts are only supported when specified as part of the transaction
697-
return false;
697+
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
698+
// Lock timeouts are only supported when specified as part of the transaction.
699+
// So technically this could be CONNECTION
700+
return LockTimeoutStyle.NONE;
698701
}
699702

700703
@Override
701-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
704+
public OuterJoinLockingType getOuterJoinLockingType() {
702705
// "WITH LOCK can only be used with a top-level, single-table SELECT statement"
703706
// https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-select.html#fblangref25-dml-with-lock
704-
return OuterJoinLockingLevel.UNSUPPORTED;
707+
return OuterJoinLockingType.UNSUPPORTED;
705708
}
706709

707710
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacyDialect.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.sql.SQLException;
1010
import java.sql.Types;
1111

12+
import jakarta.persistence.Timeout;
1213
import org.checkerframework.checker.nullness.qual.Nullable;
1314
import org.hibernate.JDBCException;
1415
import org.hibernate.LockMode;
@@ -23,6 +24,7 @@
2324
import org.hibernate.dialect.lock.LockingStrategy;
2425
import org.hibernate.dialect.lock.SelectLockingStrategy;
2526
import org.hibernate.community.dialect.pagination.LegacyHSQLLimitHandler;
27+
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
2628
import org.hibernate.dialect.pagination.LimitHandler;
2729
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
2830
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
@@ -445,8 +447,8 @@ public boolean supportsDistinctFromPredicate() {
445447
}
446448

447449
@Override
448-
public boolean supportsLockTimeouts() {
449-
return false;
450+
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
451+
return LockTimeoutStyle.NONE;
450452
}
451453

452454
@Override

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/IngresDialect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.hibernate.dialect.TimeZoneSupport;
1919
import org.hibernate.dialect.function.CommonFunctionFactory;
2020
import org.hibernate.dialect.identity.IdentityColumnSupport;
21-
import org.hibernate.dialect.lock.spi.OuterJoinLockingLevel;
21+
import org.hibernate.dialect.lock.spi.OuterJoinLockingType;
2222
import org.hibernate.dialect.pagination.LimitHandler;
2323
import org.hibernate.dialect.sequence.ANSISequenceSupport;
2424
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -422,8 +422,8 @@ public LockingClauseStrategy getLockingClauseStrategy(QuerySpec querySpec, LockO
422422
}
423423

424424
@Override
425-
public OuterJoinLockingLevel getOuterJoinLockingLevel() {
426-
return OuterJoinLockingLevel.UNSUPPORTED;
425+
public OuterJoinLockingType getOuterJoinLockingType() {
426+
return OuterJoinLockingType.UNSUPPORTED;
427427
}
428428

429429
/**

0 commit comments

Comments
 (0)