Java Code Examples for org.springframework.jdbc.core.ParameterizedPreparedStatementSetter

The following examples show how to use org.springframework.jdbc.core.ParameterizedPreparedStatementSetter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-boot   Source File: JdbcBookRepository.java    License: MIT License 6 votes vote down vote up
@Override
public int[][] batchUpdate(List<Book> books, int batchSize) {

    int[][] updateCounts = jdbcTemplate.batchUpdate(
            "update books set price = ? where id = ?",
            books,
            batchSize,
            new ParameterizedPreparedStatementSetter<Book>() {
                public void setValues(PreparedStatement ps, Book argument) throws SQLException {
                    ps.setBigDecimal(1, argument.getPrice());
                    ps.setLong(2, argument.getId());
                }
            });
    return updateCounts;

}
 
Example 2
Source Project: spring-boot   Source File: JdbcBookRepository.java    License: MIT License 6 votes vote down vote up
@Transactional
@Override
public int[][] batchInsert(List<Book> books, int batchSize) {

    int[][] updateCounts = jdbcTemplate.batchUpdate(
            "insert into books (name, price) values(?,?)",
            books,
            batchSize,
            new ParameterizedPreparedStatementSetter<Book>() {
                public void setValues(PreparedStatement ps, Book argument) throws SQLException {
                    ps.setString(1, argument.getName());
                    ps.setBigDecimal(2, argument.getPrice());
                }
            });
    return updateCounts;

}
 
Example 3
Source Project: buffer-slayer   Source File: BatchJdbcTemplate.java    License: Apache License 2.0 4 votes vote down vote up
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
    ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
  return delegate.batchUpdate(sql, batchArgs, batchSize, pss);
}
 
Example 4
Source Project: kratos-1   Source File: KratosJdbcTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
		ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {

	return super.batchUpdate(sql, batchArgs, batchSize, pss);
}