Skip to content

Commit 2350ee5

Browse files
committed
breaking change for @lock on String methods
Signed-off-by: mipo256 <[email protected]>
1 parent f3dc789 commit 2350ee5

File tree

1 file changed

+3
-71
lines changed

1 file changed

+3
-71
lines changed

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

+3-71
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,26 +27,19 @@
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;
35-
import org.springframework.core.env.StandardEnvironment;
3633
import org.springframework.data.expression.ValueEvaluationContext;
37-
import org.springframework.data.expression.ValueExpressionParser;
3834
import org.springframework.data.jdbc.core.convert.JdbcColumnTypes;
3935
import org.springframework.data.jdbc.core.convert.JdbcConverter;
4036
import org.springframework.data.jdbc.core.mapping.JdbcValue;
4137
import org.springframework.data.jdbc.support.JdbcUtil;
4238
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
4339
import org.springframework.data.relational.repository.query.RelationalParameterAccessor;
4440
import org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor;
45-
import org.springframework.data.repository.query.CachingValueExpressionDelegate;
4641
import org.springframework.data.repository.query.Parameter;
4742
import org.springframework.data.repository.query.Parameters;
48-
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
49-
import org.springframework.data.repository.query.QueryMethodValueEvaluationContextAccessor;
5043
import org.springframework.data.repository.query.ResultProcessor;
5144
import org.springframework.data.repository.query.ValueExpressionDelegate;
5245
import org.springframework.data.repository.query.ValueExpressionQueryRewriter;
@@ -80,8 +73,7 @@
8073
public class StringBasedJdbcQuery extends AbstractJdbcQuery {
8174

8275
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";
83-
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";
84-
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: ";
8577
private final JdbcConverter converter;
8678
private final RowMapperFactory rowMapperFactory;
8779
private final ValueExpressionQueryRewriter.ParsedQuery parsedQuery;
@@ -91,43 +83,6 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
9183
private final CachedResultSetExtractorFactory cachedResultSetExtractorFactory;
9284
private final ValueExpressionDelegate delegate;
9385

94-
/**
95-
* Creates a new {@link StringBasedJdbcQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
96-
* and {@link RowMapper}.
97-
*
98-
* @param queryMethod must not be {@literal null}.
99-
* @param operations must not be {@literal null}.
100-
* @param defaultRowMapper can be {@literal null} (only in case of a modifying query).
101-
* @deprecated since 3.4, use the constructors accepting {@link ValueExpressionDelegate} instead.
102-
*/
103-
@Deprecated(since = "3.4")
104-
public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations,
105-
@Nullable RowMapper<?> defaultRowMapper, JdbcConverter converter,
106-
QueryMethodEvaluationContextProvider evaluationContextProvider) {
107-
this(queryMethod.getRequiredQuery(), queryMethod, operations, result -> (RowMapper<Object>) defaultRowMapper,
108-
converter, evaluationContextProvider);
109-
}
110-
111-
/**
112-
* Creates a new {@link StringBasedJdbcQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
113-
* and {@link RowMapperFactory}.
114-
*
115-
* @param queryMethod must not be {@literal null}.
116-
* @param operations must not be {@literal null}.
117-
* @param rowMapperFactory must not be {@literal null}.
118-
* @param converter must not be {@literal null}.
119-
* @param evaluationContextProvider must not be {@literal null}.
120-
* @since 2.3
121-
* @deprecated use alternative constructor
122-
*/
123-
@Deprecated(since = "3.4")
124-
public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations,
125-
RowMapperFactory rowMapperFactory, JdbcConverter converter,
126-
QueryMethodEvaluationContextProvider evaluationContextProvider) {
127-
this(queryMethod.getRequiredQuery(), queryMethod, operations, rowMapperFactory, converter,
128-
evaluationContextProvider);
129-
}
130-
13186
/**
13287
* Creates a new {@link StringBasedJdbcQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
13388
* and {@link RowMapperFactory}.
@@ -191,35 +146,12 @@ public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedPara
191146
this.query = query;
192147

193148
if (queryMethod.hasLockMode()) {
194-
LOG.warn(LOCKING_IS_NOT_SUPPORTED);
149+
throw new UnsupportedOperationException(LOCKING_IS_NOT_SUPPORTED + queryMethod);
195150
}
196151
this.parsedQuery = rewriter.parse(this.query);
197152
this.delegate = delegate;
198153
}
199154

200-
/**
201-
* Creates a new {@link StringBasedJdbcQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
202-
* and {@link RowMapperFactory}.
203-
*
204-
* @param query must not be {@literal null} or empty.
205-
* @param queryMethod must not be {@literal null}.
206-
* @param operations must not be {@literal null}.
207-
* @param rowMapperFactory must not be {@literal null}.
208-
* @param converter must not be {@literal null}.
209-
* @param evaluationContextProvider must not be {@literal null}.
210-
* @since 3.4
211-
* @deprecated since 3.4, use the constructors accepting {@link ValueExpressionDelegate} instead.
212-
*/
213-
@Deprecated(since = "3.4")
214-
public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations,
215-
RowMapperFactory rowMapperFactory, JdbcConverter converter,
216-
QueryMethodEvaluationContextProvider evaluationContextProvider) {
217-
this(query, queryMethod, operations, rowMapperFactory, converter, new CachingValueExpressionDelegate(
218-
new QueryMethodValueEvaluationContextAccessor(new StandardEnvironment(), rootObject -> evaluationContextProvider
219-
.getEvaluationContext(queryMethod.getParameters(), new Object[] { rootObject })),
220-
ValueExpressionParser.create()));
221-
}
222-
223155
@Override
224156
public Object execute(Object[] objects) {
225157

0 commit comments

Comments
 (0)