Package com.ecom.winners.writers
Class JpaBulkItemWriter<T>
java.lang.Object
com.ecom.winners.writers.JpaBulkItemWriter<T>
- Type Parameters:
T
- an entity
- All Implemented Interfaces:
org.springframework.batch.item.ItemWriter<List<T>>
,org.springframework.beans.factory.InitializingBean
public class JpaBulkItemWriter<T>
extends Object
implements org.springframework.batch.item.ItemWriter<List<T>>, org.springframework.beans.factory.InitializingBean
JPA bulk item writer is an ItemWriter for the bulk writes of Spring Data JPA.
It's somehow a chunk bulk writer
- See Also:
-
JpaItemWriter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Asserts the state of entity manager property.void
setEntityManagerFactory
(jakarta.persistence.EntityManagerFactory entityManagerFactory) void
setUsePersist
(boolean usePersist) void
It's a wrapper around doWrite.
-
Constructor Details
-
JpaBulkItemWriter
public JpaBulkItemWriter()
-
-
Method Details
-
setEntityManagerFactory
public void setEntityManagerFactory(jakarta.persistence.EntityManagerFactory entityManagerFactory) -
setUsePersist
public void setUsePersist(boolean usePersist) -
afterPropertiesSet
public void afterPropertiesSet()Asserts the state of entity manager property.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
write
It's a wrapper around doWrite. It takes the transaction from entity manager and checks the existence of it then raise a DataAccessResourceFailure exception if the connection does not exist. If all goes well, it persists the list of items into the database.- Specified by:
write
in interfaceorg.springframework.batch.item.ItemWriter<T>
- Parameters:
listOfItems
- a chunk of items as List of generic T
-