Skip to content

Commit 14acc6f

Browse files
committed
* Implement all the delegate interfaces for the PreparedStatementCreatorWithMaxRows
1 parent 7dfc1ef commit 14acc6f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapter.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
import org.springframework.jdbc.core.ColumnMapRowMapper;
3030
import org.springframework.jdbc.core.JdbcOperations;
3131
import org.springframework.jdbc.core.JdbcTemplate;
32+
import org.springframework.jdbc.core.ParameterDisposer;
3233
import org.springframework.jdbc.core.PreparedStatementCreator;
3334
import org.springframework.jdbc.core.PreparedStatementCreatorFactory;
35+
import org.springframework.jdbc.core.PreparedStatementSetter;
3436
import org.springframework.jdbc.core.RowMapper;
3537
import org.springframework.jdbc.core.SqlProvider;
3638
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
@@ -208,7 +210,8 @@ private void executeUpdateQuery(Object obj) {
208210
this.jdbcOperations.update(this.updateSql, this.sqlParameterSourceFactory.createParameterSource(obj));
209211
}
210212

211-
private static final class PreparedStatementCreatorWithMaxRows implements PreparedStatementCreator, SqlProvider {
213+
private static final class PreparedStatementCreatorWithMaxRows
214+
implements PreparedStatementCreator, PreparedStatementSetter, SqlProvider, ParameterDisposer {
212215

213216
private final PreparedStatementCreator delegate;
214217

@@ -228,7 +231,26 @@ public PreparedStatement createPreparedStatement(Connection con) throws SQLExcep
228231

229232
@Override
230233
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+
}
232254
}
233255

234256
}

0 commit comments

Comments
 (0)