-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Document how to make Spring Batch work with Spring Data JPA repositories [BATCH-2642] #961
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
Comments
Michael Minella commented Your "fix" isn't actually correct. We'd expect you to implement a |
Petr Dvorak commented Thank you for the pointer to |
Mahmoud Ben Hassine commented The issue here is the same as BATCH-2294 and BATCH-2724 : Not being able to provide a This issue would be fixed once we are able to provide a I'm linking this to BATCH-2294 and adding it to v4.1.0.M3. |
Mahmoud Ben Hassine commented The documentation has been updated with an example of how to provide a custom In the case of this issue, it would be something like:
|
@benas I tried creating a BatchConfigurer, but I am getting an exception.
|
@kdhindsa Please ask your question on SO. The error |
Petr Dvorak opened BATCH-2642 and commented
We are using Spring Boot and we were struggling with a following issue: We needed to use our Spring Data JPA repositories (interfaces extending 'CrudRepository') in a Spring Batch writer and for some reason, the 'save(s)' method did not work for us - method got called, no exception or error was in the log, but the object was not persisted. In principle, it was exactly the same issue as the one reported here:
https://stackoverflow.com/questions/38287298/persist-issue-with-a-spring-batch-itemwriter-using-a-jpa-repository
The offending part was this one:
We finally fixed the issue by adding following code:
... and later, using autowired transaction manager for the step config:
... which replaces the default
DataSourceTransactionManager
in our extension ofDefaultBatchConfigurer
- suddenly, the data is written in the repository correctly.However, the whole fix feels a bit magical and we could use some official documentation on how to use Spring Boot Data JPA repositories inside Spring Batch writer (or other Spring Batch contexts).
Affects: 3.0.9, 4.0.1
Issue Links:
("depends on")
Referenced from: pull request #620
Backported to: 4.1.0.M3
The text was updated successfully, but these errors were encountered: