RepositoryItemWriter does not flush batch #5034
Unanswered
Walnussbaer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Simple question: why is there even a
RepositoryItemWriter
based onCrudRepository
?It does not make sense to me, because
CrudRepository
does not provide thesaveAllAndFlush
method.So to me this ItemWriter is not compatible with the rollback logic of Spring Batch. How shall Spring Batch know when to rollback if the flush is happening outside of the actual step? If something goes wrong flushing the data to the database, the writer has already returned, so Spring Batch cannot rollback the transaction and repeat the chunk.
Is this intended behaviour and do I get something wrong?
Any helpful answer is appreciated.
Also, https://docs.spring.io/spring-batch/docs/4.3.8/reference/html/readersAndWriters.html#itemWriter states the following:
After writing out the list, any flushing that may be necessary can be performed before returning from the write method. For example, if writing to a Hibernate DAO, multiple calls to write can be made, one for each item. The writer can then call flush on the hibernate session before returning.
Beta Was this translation helpful? Give feedback.
All reactions