Implement PreparedStatementCallback as lambda expression
This commit is contained in:
@@ -707,22 +707,19 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||||||
Assert.notNull(rse, "ResultSetExtractor must not be null");
|
Assert.notNull(rse, "ResultSetExtractor must not be null");
|
||||||
logger.debug("Executing prepared SQL query");
|
logger.debug("Executing prepared SQL query");
|
||||||
|
|
||||||
return execute(psc, new PreparedStatementCallback<>() {
|
return execute(psc, (PreparedStatementCallback<T>) ps -> {
|
||||||
@Override
|
ResultSet rs = null;
|
||||||
public @Nullable T doInPreparedStatement(PreparedStatement ps) throws SQLException {
|
try {
|
||||||
ResultSet rs = null;
|
if (pss != null) {
|
||||||
try {
|
pss.setValues(ps);
|
||||||
if (pss != null) {
|
|
||||||
pss.setValues(ps);
|
|
||||||
}
|
|
||||||
rs = ps.executeQuery();
|
|
||||||
return rse.extractData(rs);
|
|
||||||
}
|
}
|
||||||
finally {
|
rs = ps.executeQuery();
|
||||||
JdbcUtils.closeResultSet(rs);
|
return rse.extractData(rs);
|
||||||
if (pss instanceof ParameterDisposer parameterDisposer) {
|
}
|
||||||
parameterDisposer.cleanupParameters();
|
finally {
|
||||||
}
|
JdbcUtils.closeResultSet(rs);
|
||||||
|
if (pss instanceof ParameterDisposer parameterDisposer) {
|
||||||
|
parameterDisposer.cleanupParameters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user