From a7a9fbca5d037677b7f38ffa0dec88e277f9164c Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Mon, 10 Mar 2025 15:18:48 +0100 Subject: [PATCH] Polishing. Refining documentation. Original pull request #2008 --- .../jdbc/repository/query/StringBasedJdbcQuery.java | 6 ++---- .../antora/modules/ROOT/pages/jdbc/transactions.adoc | 10 ++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java index efa4c4ca5..7c4ff0d78 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java @@ -140,8 +140,7 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery { * @since 3.4 */ public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations, - RowMapperFactory rowMapperFactory, JdbcConverter converter, - ValueExpressionDelegate delegate) { + RowMapperFactory rowMapperFactory, JdbcConverter converter, ValueExpressionDelegate delegate) { this(queryMethod.getRequiredQuery(), queryMethod, operations, rowMapperFactory, converter, delegate); } @@ -158,8 +157,7 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery { * @since 3.4 */ public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations, - RowMapperFactory rowMapperFactory, JdbcConverter converter, - ValueExpressionDelegate delegate) { + RowMapperFactory rowMapperFactory, JdbcConverter converter, ValueExpressionDelegate delegate) { super(queryMethod, operations); Assert.hasText(query, "Query must not be null or empty"); Assert.notNull(rowMapperFactory, "RowMapperFactory must not be null"); diff --git a/src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc b/src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc index 84b48ad23..b16b44b33 100644 --- a/src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc +++ b/src/main/antora/modules/ROOT/pages/jdbc/transactions.adoc @@ -101,10 +101,6 @@ The required value of type `LockMode` offers two values: `PESSIMISTIC_READ` whic Some databases do not make this distinction. In that cases both modes are equivalent of `PESSIMISTIC_WRITE`. -NOTE: It is worth stating explicitly, that `@Lock` currently is not supported on string-based queries. It means, -that queries in the repository, created with `@Query`, will ignore the locking information provided by the `@Lock`, -Using `@Lock` on string-based queries will result in the warning in logs. - .Using @Lock on derived query method [source,java] ---- @@ -123,3 +119,9 @@ If you are using a databse with the MySQL Dialect this will result for example i ---- Select * from user u where u.lastname = lastname LOCK IN SHARE MODE ---- + +NOTE: `@Lock` is currently not supported on string-based queries. +Query-methods created with `@Query`, will ignore the locking information provided by the `@Lock`, +Using `@Lock` on string-based queries will result in the warning in logs. +Future versions will throw an exception. +