I'm using spring-batch and composing 'ChunkOrientedTasklet'.
I saw the image above and realized that the reader and writer operate as a single transaction.
But it wasn't.
Why spring-batch reader and writer use different transactions?
So, reader and writer use different persistence context.
As a result, the select query occurs twice. 1 time for each page unit in the reader, 1 time for each merge in the writer (Because the transaction is different, the entity is not fetched from the persistence context, and a new entity is fetched by querying the DB)
Select queries continue to occur in Writer in inserts, updates, and unchanged situations
reader - QuerydslPagingItemReader (wrapped with JpaPagingItemReader) writer - CustomItemWriter (wrapped with JpaItemWriter)
[Result]