Added AbstractCursorItemReader.connectionAutoCommit #446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a follow up of discussion in PR spring-projects/spring-boot#7866
The use case was to use a JdbcCursorItemReader with PostgreSQL (nothing fancy here).
From https://jdbc.postgresql.org/documentation/94/query.html, section "Getting results based on a cursor", the connection must not be in auto commit mode.
But JdbcCursorItemReader does not allow to explicity set connection mode to autoCommit = false.
As discussed in the Spring Boot PR, configuring the JDBC pool to force all connection to autoCommit=false is not an optimal way to workaround the problem.
So here's a little PR that allows configuration of autocommit mode for the connection used by a CursorItemReader.
I validated the use of a Boolean wrapper against https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SingleConnectionDataSource.java#L65, to keep Spring philosophy.
Hope this helps,
Guillaume