Skip to content

Commit 2176936

Browse files
mipo256schauder
authored andcommitted
Fail on annotated query methods with @Lock.
Query methods that are not derived methods now cause an exception, when they are annotated with `@Lock`, since this combination is not supported. Before they just logged a warning. Comment edited by Jens Schauder Signed-off-by: mipo256 <[email protected]>
1 parent 639a093 commit 2176936

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.jdbc.repository.query;
1717

18-
import static org.springframework.data.jdbc.repository.query.JdbcQueryExecution.*;
18+
import static org.springframework.data.jdbc.repository.query.JdbcQueryExecution.ResultProcessingConverter;
1919

2020
import java.lang.reflect.Array;
2121
import java.lang.reflect.Constructor;
@@ -27,8 +27,6 @@
2727
import java.util.function.Function;
2828
import java.util.function.Supplier;
2929

30-
import org.apache.commons.logging.Log;
31-
import org.apache.commons.logging.LogFactory;
3230
import org.springframework.beans.BeanInstantiationException;
3331
import org.springframework.beans.BeanUtils;
3432
import org.springframework.beans.factory.BeanFactory;
@@ -75,8 +73,7 @@
7573
public class StringBasedJdbcQuery extends AbstractJdbcQuery {
7674

7775
private static final String PARAMETER_NEEDS_TO_BE_NAMED = "For queries with named parameters you need to provide names for method parameters; Use @Param for query method parameters, or use the javac flag -parameters";
78-
private final static String LOCKING_IS_NOT_SUPPORTED = "Currently, @Lock is supported only on derived queries. In other words, for queries created with @Query, the locking condition specified with @Lock does nothing";
79-
private static final Log LOG = LogFactory.getLog(StringBasedJdbcQuery.class);
76+
private final static String LOCKING_IS_NOT_SUPPORTED = "Currently, @Lock is supported only on derived queries. In other words, for queries created with @Query, the locking condition specified with @Lock does nothing. Offending method: ";
8077
private final JdbcConverter converter;
8178
private final RowMapperFactory rowMapperFactory;
8279
private final ValueExpressionQueryRewriter.ParsedQuery parsedQuery;
@@ -149,7 +146,7 @@ public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedPara
149146
this.query = query;
150147

151148
if (queryMethod.hasLockMode()) {
152-
LOG.warn(LOCKING_IS_NOT_SUPPORTED);
149+
throw new UnsupportedOperationException(LOCKING_IS_NOT_SUPPORTED + queryMethod);
153150
}
154151
this.parsedQuery = rewriter.parse(this.query);
155152
this.delegate = delegate;

0 commit comments

Comments
 (0)