Skip to content

Add option to clear the persistence context in JpaItemWriter #804

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions