Class JpaItemWriterBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.JpaItemWriterBuilder<T>
A builder for the
JpaItemWriter
.- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine, Jinwoo Bae
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a fully builtJpaItemWriter
.clearPersistenceContext
(boolean clearPersistenceContext) If set to false, theEntityManager
will not be cleared at the end of the chunk. defaults to trueentityManagerFactory
(jakarta.persistence.EntityManagerFactory entityManagerFactory) The JPAEntityManagerFactory
to obtain an entity manager from.usePersist
(boolean usePersist) Set whether the entity manager should perform a persist instead of a merge.
-
Constructor Details
-
JpaItemWriterBuilder
public JpaItemWriterBuilder()
-
-
Method Details
-
entityManagerFactory
public JpaItemWriterBuilder<T> entityManagerFactory(jakarta.persistence.EntityManagerFactory entityManagerFactory) The JPAEntityManagerFactory
to obtain an entity manager from. Required.- Parameters:
entityManagerFactory
- theEntityManagerFactory
- Returns:
- this instance for method chaining
- See Also:
-
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
If set to false, theEntityManager
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
Returns a fully builtJpaItemWriter
.- Returns:
- the writer
-