Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of this spring class BatchPreparedStatementSetter?

Can anyone give me short description about his spring class

org.springframework.jdbc.core.BatchPreparedStatementSetter

(JavaDoc API Link)

like image 822
Mohamed Saligh Avatar asked Dec 01 '10 06:12

Mohamed Saligh


People also ask

How does JdbcTemplate batchUpdate works?

Using the JdbcTemplate batch processing is accomplished by implementing a special interface, BatchPreparedStatementSetter , and passing that in as the second parameter in your batchUpdate method call. This interface has two methods you must implement.

What does Batch update return?

All batch update methods return an int array containing the number of affected rows for each batch entry. This count is reported by the JDBC driver and it's not always available in which case the JDBC driver simply returns a -2 value.

What is Spring JDBC?

Spring Data JDBC, part of the larger Spring Data family, makes it easy to implement JDBC based repositories. This module deals with enhanced support for JDBC based data access layers. It makes it easier to build Spring powered applications that use data access technologies.

Is JdbcTemplate batchUpdate transactional?

Insert batch example using JdbcTemplate batchUpdate() operation. Batch Insert/Update operations must be Transactional. For batch operations you can use batch update callback BatchPreparedStatementSetter to set parameter values.


1 Answers

It's used for bulk insertion of many rows at once.

This code will illustrate how it's used.

Take a good look at importEmployees method, and everything should become clear.

like image 93
darioo Avatar answered Oct 24 '22 09:10

darioo