Package org.springframework.batch.item.database.builder

# 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
See Also:
  - `JpaItemWriter`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JpaItemWriterBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `JpaItemWriter<T>`
  `build()`
  Returns a fully built `JpaItemWriter`.
  `JpaItemWriterBuilder<T>`
  `entityManagerFactory(jakarta.persistence.EntityManagerFactory entityManagerFactory)`
  The JPA `EntityManagerFactory` to obtain an entity manager from.
  `JpaItemWriterBuilder<T>`
  `usePersist(boolean usePersist)`
  Set whether the entity manager should perform a persist instead of a merge.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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:
      - `JpaItemWriter.setEntityManagerFactory(EntityManagerFactory)`

  - ### 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:
      - `JpaItemWriter.setUsePersist(boolean)`

  - ### build

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