Skip to content

Added connectionAutoCommit property in JdbcCursorItemReaderBuilder #3718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class JdbcCursorItemReaderBuilder<T> {

private int currentItemCount;

private boolean connectionAutoCommit;

/**
* Configure if the state of the {@link org.springframework.batch.item.ItemStreamSupport}
* should be persisted within the {@link org.springframework.batch.item.ExecutionContext}
Expand Down Expand Up @@ -308,15 +310,15 @@ public JdbcCursorItemReaderBuilder<T> rowMapper(RowMapper<T> rowMapper) {
}

/**
* Creates a {@link BeanPropertyRowMapper} to be used as your
* {@link RowMapper}.
* Set whether "autoCommit" should be overridden for the connection used by the cursor. If not set, defaults to
* Connection / Datasource default configuration.
*
* @param mappedClass the class for the row mapper
* @param connectionAutoCommit value to set on underlying JDBC connection
* @return this instance for method chaining
* @see BeanPropertyRowMapper
* @see JdbcCursorItemReader#setConnectionAutoCommit(boolean)
*/
public JdbcCursorItemReaderBuilder<T> beanRowMapper(Class<T> mappedClass) {
this.rowMapper = new BeanPropertyRowMapper<>(mappedClass);
public JdbcCursorItemReaderBuilder<T> connectionAutoCommit(boolean connectionAutoCommit) {
this.connectionAutoCommit = connectionAutoCommit;

return this;
}
Expand Down Expand Up @@ -356,6 +358,7 @@ public JdbcCursorItemReader<T> build() {
reader.setQueryTimeout(this.queryTimeout);
reader.setUseSharedExtendedConnection(this.useSharedExtendedConnection);
reader.setVerifyCursorPosition(this.verifyCursorPosition);
reader.setConnectionAutoCommit(this.connectionAutoCommit);

return reader;
}
Expand Down
Loading