|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 org.apache.commons.logging.Log |
logger
|
| Constructor Summary | |
|---|---|
JpaItemWriter()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Check mandatory properties - there must be an entityManagerFactory. |
protected void |
doWrite(javax.persistence.EntityManager entityManager,
java.util.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(java.util.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 org.apache.commons.logging.Log logger
| Constructor Detail |
|---|
public JpaItemWriter()
| Method Detail |
|---|
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
entityManagerFactory - the entityManagerFactory to set
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exception
public final void write(java.util.List<? extends T> items)
throws java.lang.Exception
write in interface ItemWriter<T>java.lang.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,
java.util.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 | |||||||||