Class JpaItemWriterBuilder<T>

java.lang.Object
org.springframework.batch.item.database.builder.JpaItemWriterBuilder<T>

public class JpaItemWriterBuilder<T> extends Object
A builder for the JpaItemWriter.
Since:
4.1
Author:
Mahmoud Ben Hassine, Jinwoo Bae
See Also:
  • Constructor Details

    • JpaItemWriterBuilder

      public JpaItemWriterBuilder()
  • Method Details

    • entityManagerFactory

      public JpaItemWriterBuilder<T> entityManagerFactory(jakarta.persistence.EntityManagerFactory entityManagerFactory)
      The JPA EntityManagerFactory to obtain an entity manager from. Required.
      Parameters:
      entityManagerFactory - the EntityManagerFactory
      Returns:
      this instance for method chaining
      See Also:
    • usePersist

      public JpaItemWriterBuilder<T> usePersist(boolean usePersist)
      Set whether the entity manager should perform a persist instead of a merge.
      Parameters:
      usePersist - defaults to false
      Returns:
      this instance for method chaining
      See Also:
    • clearPersistenceContext

      public JpaItemWriterBuilder<T> clearPersistenceContext(boolean clearPersistenceContext)
      If set to false, the EntityManager will not be cleared at the end of the chunk. defaults to true
      Parameters:
      clearPersistenceContext - true if the persistence context should be cleared after writing items, false otherwise
      Returns:
      this instance for method chaining
      Since:
      5.1
      See Also:
    • build

      public JpaItemWriter<T> build()
      Returns a fully built JpaItemWriter.
      Returns:
      the writer