29
29
import org .springframework .jdbc .core .ColumnMapRowMapper ;
30
30
import org .springframework .jdbc .core .JdbcOperations ;
31
31
import org .springframework .jdbc .core .JdbcTemplate ;
32
+ import org .springframework .jdbc .core .ParameterDisposer ;
32
33
import org .springframework .jdbc .core .PreparedStatementCreator ;
33
34
import org .springframework .jdbc .core .PreparedStatementCreatorFactory ;
35
+ import org .springframework .jdbc .core .PreparedStatementSetter ;
34
36
import org .springframework .jdbc .core .RowMapper ;
35
37
import org .springframework .jdbc .core .SqlProvider ;
36
38
import org .springframework .jdbc .core .namedparam .NamedParameterJdbcOperations ;
@@ -208,7 +210,8 @@ private void executeUpdateQuery(Object obj) {
208
210
this .jdbcOperations .update (this .updateSql , this .sqlParameterSourceFactory .createParameterSource (obj ));
209
211
}
210
212
211
- private static final class PreparedStatementCreatorWithMaxRows implements PreparedStatementCreator , SqlProvider {
213
+ private static final class PreparedStatementCreatorWithMaxRows
214
+ implements PreparedStatementCreator , PreparedStatementSetter , SqlProvider , ParameterDisposer {
212
215
213
216
private final PreparedStatementCreator delegate ;
214
217
@@ -228,7 +231,26 @@ public PreparedStatement createPreparedStatement(Connection con) throws SQLExcep
228
231
229
232
@ Override
230
233
public String getSql () {
231
- return ((SqlProvider ) this .delegate ).getSql ();
234
+ if (this .delegate instanceof SqlProvider ) {
235
+ return ((SqlProvider ) this .delegate ).getSql ();
236
+ }
237
+ else {
238
+ return null ;
239
+ }
240
+ }
241
+
242
+ @ Override
243
+ public void setValues (PreparedStatement ps ) throws SQLException {
244
+ if (this .delegate instanceof PreparedStatementSetter ) {
245
+ ((PreparedStatementSetter ) this .delegate ).setValues (ps );
246
+ }
247
+ }
248
+
249
+ @ Override
250
+ public void cleanupParameters () {
251
+ if (this .delegate instanceof ParameterDisposer ) {
252
+ ((ParameterDisposer ) this .delegate ).cleanupParameters ();
253
+ }
232
254
}
233
255
234
256
}
0 commit comments