|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.database.JpaItemWriter<T>
public class JpaItemWriter<T>
ItemWriter
that is using a JPA
EntityManagerFactory to merge any Entities that aren't part of the
persistence context.
It is required that write(List)
is called inside a transaction.
The reader must be configured with an
EntityManagerFactory
that is capable of
participating in Spring managed transactions.
The writer is thread safe after its properties are set (normal singleton
behaviour), so it can be used to write in multiple concurrent transactions.
Field Summary | |
---|---|
protected static Log |
logger
|
Constructor Summary | |
---|---|
JpaItemWriter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Check mandatory properties - there must be an entityManagerFactory. |
protected void |
doWrite(javax.persistence.EntityManager entityManager,
List<? extends T> items)
Do perform the actual write operation. |
void |
setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
Set the EntityManager to be used internally. |
void |
write(List<? extends T> items)
Merge all provided items that aren't already in the persistence context and then flush and clear the entity manager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Log logger
Constructor Detail |
---|
public JpaItemWriter()
Method Detail |
---|
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
entityManagerFactory
- the entityManagerFactory to setpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public final void write(List<? extends T> items) throws Exception
write
in interface ItemWriter<T>
Exception
- if there are errors. The framework will catch the
exception and convert or rethrow it as appropriate.ItemWriter.write(java.util.List)
protected void doWrite(javax.persistence.EntityManager entityManager, List<? extends T> items)
entityManager
- the EntityManager to use for the operationitems
- the list of items to use for the write
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |