From 23fecb110d3f2ca7379123a960950be95c1bd127 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 6 May 2024 17:25:34 +0200 Subject: [PATCH] HHH-17421 Ensure that no follow-on locking happens on SQL Server and Sybase ASE --- .../dialect/SQLServerLegacySqlAstTranslator.java | 9 +++++++++ .../dialect/SybaseASELegacySqlAstTranslator.java | 9 +++++++++ .../community/dialect/SybaseLegacySqlAstTranslator.java | 9 +++++++++ .../org/hibernate/dialect/SQLServerSqlAstTranslator.java | 9 +++++++++ .../org/hibernate/dialect/SybaseASESqlAstTranslator.java | 9 +++++++++ .../org/hibernate/dialect/SybaseSqlAstTranslator.java | 9 +++++++++ 6 files changed, 54 insertions(+) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacySqlAstTranslator.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacySqlAstTranslator.java index 20495884f9..2b744a2b84 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacySqlAstTranslator.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacySqlAstTranslator.java @@ -293,6 +293,15 @@ public class SQLServerLegacySqlAstTranslator extends Ab } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // SQL Server does not support the FOR UPDATE clause diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseASELegacySqlAstTranslator.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseASELegacySqlAstTranslator.java index be42647e43..b5ace75909 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseASELegacySqlAstTranslator.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseASELegacySqlAstTranslator.java @@ -271,6 +271,15 @@ public class SybaseASELegacySqlAstTranslator extends Ab } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // Sybase ASE does not really support the FOR UPDATE clause diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseLegacySqlAstTranslator.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseLegacySqlAstTranslator.java index 602992915c..90db1a23af 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseLegacySqlAstTranslator.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseLegacySqlAstTranslator.java @@ -183,6 +183,15 @@ public class SybaseLegacySqlAstTranslator extends Abstr } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // Sybase does not support the FOR UPDATE clause diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java index e1973f09a7..e300ae7f41 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java @@ -271,6 +271,15 @@ public class SQLServerSqlAstTranslator extends SqlAstTr } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // SQL Server does not support the FOR UPDATE clause diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASESqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASESqlAstTranslator.java index fa67be5630..eee92fa20b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASESqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASESqlAstTranslator.java @@ -256,6 +256,15 @@ public class SybaseASESqlAstTranslator extends Abstract } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // Sybase ASE does not really support the FOR UPDATE clause diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseSqlAstTranslator.java index e4774530af..fad5c38caf 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseSqlAstTranslator.java @@ -182,6 +182,15 @@ public class SybaseSqlAstTranslator extends AbstractSql } } + @Override + protected LockStrategy determineLockingStrategy( + QuerySpec querySpec, + ForUpdateClause forUpdateClause, + Boolean followOnLocking) { + // No need for follow on locking + return LockStrategy.CLAUSE; + } + @Override protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) { // Sybase does not support the FOR UPDATE clause