Description
Mahmoud Ben Hassine opened BATCH-2797 and commented
The HibernateItemWriter
provides a parameter named clearSession
to clear the session after writing items. However, the JpaItemWriter
does not provide such an option, which may lead to some OOM errors (see SO thread in reference URL).
For the record, both JpaItemWriter
and HibernateItemWriter
used to clear the persistent context but this has been removed in BATCH-1635. However, this has been re-added and made configurable in the HibernateItemWriter
in BATCH-1759 through the clearSession
parameter but not in the JpaItemWriter
.
For consistency with HibernateItemWriter
, the JpaItemWriter
should provide a parameter called clearPersistenceContext
to clear the persistence context after writing items.
Reference URL: https://stackoverflow.com/questions/54746793/spring-batch-memory-leak-csv-to-database-using-jpaitemwriter