@@ -72,20 +72,20 @@ class StoredProcedure {
72
72
73
73
private final Class <?> returnType ;
74
74
75
+ private final VirtualShardKeyStrategy shardStrategy ;
76
+ private final List <ShardKeyParameter > shardKeyParameters ;
77
+ private final boolean autoPartition ;
78
+
75
79
// whether the result type is a collection (List)
76
80
private final boolean collectionResult ;
77
81
private final boolean runOnAllShards ;
78
82
private final boolean searchShards ;
79
- private final boolean autoPartition ;
80
83
private final boolean parallel ;
81
84
private final boolean readOnly ;
82
85
private final WriteTransaction writeTransaction ;
83
86
84
87
private final Executor executor ;
85
88
86
- private final VirtualShardKeyStrategy shardStrategy ;
87
- private final List <ShardKeyParameter > shardKeyParameters ;
88
-
89
89
private static final Executor MULTI_ROW_SIMPLE_TYPE_EXECUTOR = new MultiRowSimpleTypeExecutor ();
90
90
private static final Executor MULTI_ROW_TYPE_MAPPER_EXECUTOR = new MultiRowTypeMapperExecutor ();
91
91
private static final Executor SINGLE_ROW_SIMPLE_TYPE_EXECUTOR = new SingleRowSimpleTypeExecutor ();
@@ -106,6 +106,10 @@ public StoredProcedure(final String name, final String query, final List<StoredP
106
106
this .sqlParameterList = createSqlParameterList (params );
107
107
this .query = (query != null ? query : defaultQuery (name , sqlParameterList ));
108
108
109
+ this .shardStrategy = sStrategy ;
110
+ this .shardKeyParameters = new ArrayList <>(shardKeyParameters );
111
+ this .autoPartition = isAutoPartition (shardKeyParameters );
112
+
109
113
this .runOnAllShards = runOnAllShards ;
110
114
this .searchShards = searchShards ;
111
115
this .parallel = parallel ;
@@ -115,11 +119,6 @@ public StoredProcedure(final String name, final String query, final List<StoredP
115
119
this .adivsoryLock = advisoryLock ;
116
120
this .timeout = timeout ;
117
121
118
- this .shardStrategy = sStrategy ;
119
- this .shardKeyParameters = new ArrayList <>(shardKeyParameters );
120
-
121
- this .autoPartition = isAutoPartition (shardKeyParameters );
122
-
123
122
ValueTransformer <?, ?> valueTransformerForClass = null ;
124
123
Executor exec ;
125
124
if (genericType instanceof ParameterizedType ) {
@@ -246,6 +245,10 @@ public String getSqlParameterList() {
246
245
return sqlParameterList ;
247
246
}
248
247
248
+ public String getQuery () {
249
+ return query ;
250
+ }
251
+
249
252
private static String createSqlParameterList (final List <StoredProcedureParameter > params ) {
250
253
String s = "" ;
251
254
boolean first = true ;
@@ -262,14 +265,19 @@ private static String createSqlParameterList(final List<StoredProcedureParameter
262
265
return s ;
263
266
}
264
267
265
- public String getQuery () {
266
- return query ;
267
- }
268
-
269
268
private static String defaultQuery (final String name , final String sqlParameterList ) {
270
269
return "SELECT * FROM " + name + " ( " + sqlParameterList + " )" ;
271
270
}
272
271
272
+ private static boolean isAutoPartition (final List <ShardKeyParameter > shardKeyParameters ) {
273
+ for (ShardKeyParameter p : shardKeyParameters ) {
274
+ if (List .class .isAssignableFrom (p .getType ())) {
275
+ return true ;
276
+ }
277
+ }
278
+ return false ;
279
+ }
280
+
273
281
/**
274
282
* build execution string like create_or_update_multiple_objects({"(a,b)","(c,d)" }).
275
283
*
@@ -376,15 +384,6 @@ private Map<Integer, Object[]> partitionArguments(final DataSourceProvider dataS
376
384
return argumentsByShardId ;
377
385
}
378
386
379
- private boolean isAutoPartition (final List <ShardKeyParameter > shardKeyParameters ) {
380
- for (ShardKeyParameter p : shardKeyParameters ) {
381
- if (List .class .isAssignableFrom (p .getType ())) {
382
- return true ;
383
- }
384
- }
385
- return false ;
386
- }
387
-
388
387
@ Immutable
389
388
private static final class Call implements Callable <Object > {
390
389
0 commit comments