@@ -159,10 +159,7 @@ private Entry<String, KeyAssigner> getAssignerForParamMap(Configuration config,
159
159
int firstDot = keyProperty .indexOf ('.' );
160
160
if (firstDot == -1 ) {
161
161
if (singleParam ) {
162
- // Assume 'keyProperty' to be a property of the single param.
163
- String singleParamName = nameOfSingleParam (paramMap );
164
- String argParamName = omitParamName ? null : singleParamName ;
165
- return entry (singleParamName , new KeyAssigner (config , rsmd , columnPosition , argParamName , keyProperty ));
162
+ return getAssignerForSingleParam (config , rsmd , columnPosition , paramMap , keyProperty , omitParamName );
166
163
}
167
164
throw new ExecutorException ("Could not determine which parameter to assign generated keys to. "
168
165
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
@@ -175,10 +172,7 @@ private Entry<String, KeyAssigner> getAssignerForParamMap(Configuration config,
175
172
String argKeyProperty = keyProperty .substring (firstDot + 1 );
176
173
return entry (paramName , new KeyAssigner (config , rsmd , columnPosition , argParamName , argKeyProperty ));
177
174
} else if (singleParam ) {
178
- // Assume 'keyProperty' to be a property of the single param.
179
- String singleParamName = nameOfSingleParam (paramMap );
180
- String argParamName = omitParamName ? null : singleParamName ;
181
- return entry (singleParamName , new KeyAssigner (config , rsmd , columnPosition , argParamName , keyProperty ));
175
+ return getAssignerForSingleParam (config , rsmd , columnPosition , paramMap , keyProperty , omitParamName );
182
176
} else {
183
177
throw new ExecutorException ("Could not find parameter '" + paramName + "'. "
184
178
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
@@ -187,6 +181,14 @@ private Entry<String, KeyAssigner> getAssignerForParamMap(Configuration config,
187
181
}
188
182
}
189
183
184
+ private Entry <String , KeyAssigner > getAssignerForSingleParam (Configuration config , ResultSetMetaData rsmd ,
185
+ int columnPosition , Map <String , ?> paramMap , String keyProperty , boolean omitParamName ) {
186
+ // Assume 'keyProperty' to be a property of the single param.
187
+ String singleParamName = nameOfSingleParam (paramMap );
188
+ String argParamName = omitParamName ? null : singleParamName ;
189
+ return entry (singleParamName , new KeyAssigner (config , rsmd , columnPosition , argParamName , keyProperty ));
190
+ }
191
+
190
192
private static String nameOfSingleParam (Map <String , ?> paramMap ) {
191
193
// There is virtually one parameter, so any key works.
192
194
return paramMap .keySet ().iterator ().next ();
@@ -208,13 +210,13 @@ private static <K, V> Entry<K, V> entry(K key, V value) {
208
210
}
209
211
210
212
private class KeyAssigner {
211
- protected final Configuration configuration ;
212
- protected final ResultSetMetaData rsmd ;
213
- protected final TypeHandlerRegistry typeHandlerRegistry ;
214
- protected final int columnPosition ;
215
- protected final String paramName ;
216
- protected final String propertyName ;
217
- protected TypeHandler <?> typeHandler ;
213
+ private final Configuration configuration ;
214
+ private final ResultSetMetaData rsmd ;
215
+ private final TypeHandlerRegistry typeHandlerRegistry ;
216
+ private final int columnPosition ;
217
+ private final String paramName ;
218
+ private final String propertyName ;
219
+ private TypeHandler <?> typeHandler ;
218
220
219
221
protected KeyAssigner (Configuration configuration , ResultSetMetaData rsmd , int columnPosition , String paramName ,
220
222
String propertyName ) {
0 commit comments