15
15
*/
16
16
package org .springframework .data .jdbc .repository .query ;
17
17
18
- import static org .springframework .data .jdbc .repository .query .JdbcQueryExecution .* ;
18
+ import static org .springframework .data .jdbc .repository .query .JdbcQueryExecution .ResultProcessingConverter ;
19
19
20
20
import java .lang .reflect .Array ;
21
21
import java .lang .reflect .Constructor ;
27
27
import java .util .function .Function ;
28
28
import java .util .function .Supplier ;
29
29
30
- import org .apache .commons .logging .Log ;
31
- import org .apache .commons .logging .LogFactory ;
32
30
import org .springframework .beans .BeanInstantiationException ;
33
31
import org .springframework .beans .BeanUtils ;
34
32
import org .springframework .beans .factory .BeanFactory ;
35
- import org .springframework .core .env .StandardEnvironment ;
36
33
import org .springframework .data .expression .ValueEvaluationContext ;
37
- import org .springframework .data .expression .ValueExpressionParser ;
38
34
import org .springframework .data .jdbc .core .convert .JdbcColumnTypes ;
39
35
import org .springframework .data .jdbc .core .convert .JdbcConverter ;
40
36
import org .springframework .data .jdbc .core .mapping .JdbcValue ;
41
37
import org .springframework .data .jdbc .support .JdbcUtil ;
42
38
import org .springframework .data .relational .core .mapping .RelationalMappingContext ;
43
39
import org .springframework .data .relational .repository .query .RelationalParameterAccessor ;
44
40
import org .springframework .data .relational .repository .query .RelationalParametersParameterAccessor ;
45
- import org .springframework .data .repository .query .CachingValueExpressionDelegate ;
46
41
import org .springframework .data .repository .query .Parameter ;
47
42
import org .springframework .data .repository .query .Parameters ;
48
- import org .springframework .data .repository .query .QueryMethodEvaluationContextProvider ;
49
- import org .springframework .data .repository .query .QueryMethodValueEvaluationContextAccessor ;
50
43
import org .springframework .data .repository .query .ResultProcessor ;
51
44
import org .springframework .data .repository .query .ValueExpressionDelegate ;
52
45
import org .springframework .data .repository .query .ValueExpressionQueryRewriter ;
80
73
public class StringBasedJdbcQuery extends AbstractJdbcQuery {
81
74
82
75
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: " ;
85
77
private final JdbcConverter converter ;
86
78
private final RowMapperFactory rowMapperFactory ;
87
79
private final ValueExpressionQueryRewriter .ParsedQuery parsedQuery ;
@@ -91,43 +83,6 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
91
83
private final CachedResultSetExtractorFactory cachedResultSetExtractorFactory ;
92
84
private final ValueExpressionDelegate delegate ;
93
85
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
-
131
86
/**
132
87
* Creates a new {@link StringBasedJdbcQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
133
88
* and {@link RowMapperFactory}.
@@ -191,35 +146,12 @@ public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedPara
191
146
this .query = query ;
192
147
193
148
if (queryMethod .hasLockMode ()) {
194
- LOG . warn (LOCKING_IS_NOT_SUPPORTED );
149
+ throw new UnsupportedOperationException (LOCKING_IS_NOT_SUPPORTED + queryMethod );
195
150
}
196
151
this .parsedQuery = rewriter .parse (this .query );
197
152
this .delegate = delegate ;
198
153
}
199
154
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
-
223
155
@ Override
224
156
public Object execute (Object [] objects ) {
225
157
0 commit comments