15
15
*/
16
16
package org .springframework .data .jdbc .repository .query ;
17
17
18
- import java .sql .SQLType ;
19
18
import java .util .List ;
19
+ import java .util .function .Function ;
20
20
21
21
import org .springframework .core .MethodParameter ;
22
- import org .springframework .data .jdbc .core .convert .JdbcColumnTypes ;
23
- import org .springframework .data .jdbc .support .JdbcUtil ;
24
22
import org .springframework .data .relational .repository .query .RelationalParameters ;
25
- import org .springframework .data .repository .query .Parameter ;
23
+ import org .springframework .data .relational . repository .query .RelationalParameters . RelationalParameter ;
26
24
import org .springframework .data .repository .query .ParametersSource ;
27
- import org .springframework .data .util .Lazy ;
28
- import org .springframework .data .util .TypeInformation ;
29
25
30
26
/**
31
27
* Custom extension of {@link RelationalParameters}.
32
28
*
33
29
* @author Mark Paluch
30
+ * @author Mikhail Polivakha
34
31
* @since 3.2.6
35
32
*/
36
33
public class JdbcParameters extends RelationalParameters {
@@ -41,8 +38,17 @@ public class JdbcParameters extends RelationalParameters {
41
38
* @param parametersSource must not be {@literal null}.
42
39
*/
43
40
public JdbcParameters (ParametersSource parametersSource ) {
44
- super (parametersSource ,
45
- methodParameter -> new JdbcParameter (methodParameter , parametersSource .getDomainTypeInformation ()));
41
+ this (parametersSource , methodParameter -> new JdbcParameter (methodParameter , parametersSource .getDomainTypeInformation ()));
42
+ }
43
+
44
+ /**
45
+ * Creates a new {@link JdbcParameters} instance from the given {@link ParametersSource} and function
46
+ * of turning the {@link MethodParameter} into {@link RelationalParameter}.
47
+ *
48
+ * @param parametersSource must not be {@literal null}.
49
+ */
50
+ public JdbcParameters (ParametersSource parametersSource , Function <MethodParameter , RelationalParameter > parameterFactory ) {
51
+ super (parametersSource , parameterFactory );
46
52
}
47
53
48
54
@ SuppressWarnings ({ "rawtypes" , "unchecked" })
@@ -61,39 +67,4 @@ protected JdbcParameters createFrom(List<RelationalParameter> parameters) {
61
67
return new JdbcParameters ((List ) parameters );
62
68
}
63
69
64
- /**
65
- * Custom {@link Parameter} implementation.
66
- *
67
- * @author Mark Paluch
68
- * @author Chirag Tailor
69
- */
70
- public static class JdbcParameter extends RelationalParameter {
71
-
72
- private final SQLType sqlType ;
73
- private final Lazy <SQLType > actualSqlType ;
74
-
75
- /**
76
- * Creates a new {@link RelationalParameter}.
77
- *
78
- * @param parameter must not be {@literal null}.
79
- */
80
- JdbcParameter (MethodParameter parameter , TypeInformation <?> domainType ) {
81
- super (parameter , domainType );
82
-
83
- TypeInformation <?> typeInformation = getTypeInformation ();
84
-
85
- sqlType = JdbcUtil .targetSqlTypeFor (JdbcColumnTypes .INSTANCE .resolvePrimitiveType (typeInformation .getType ()));
86
-
87
- actualSqlType = Lazy .of (() -> JdbcUtil
88
- .targetSqlTypeFor (JdbcColumnTypes .INSTANCE .resolvePrimitiveType (typeInformation .getActualType ().getType ())));
89
- }
90
-
91
- public SQLType getSqlType () {
92
- return sqlType ;
93
- }
94
-
95
- public SQLType getActualSqlType () {
96
- return actualSqlType .get ();
97
- }
98
- }
99
70
}
0 commit comments