类 JpaItemWriter<T>

  • 所有已实现的接口:
    ItemWriter<T>, org.springframework.beans.factory.InitializingBean

    public class JpaItemWriter<T>
    extends java.lang.Object
    implements ItemWriter<T>, org.springframework.beans.factory.InitializingBean
    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.
    作者:
    Thomas Risberg
    • 字段概要

      字段 
      修饰符和类型字段说明
      protected static org.apache.commons.logging.Loglogger 
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型方法说明
      voidafterPropertiesSet()
      Check mandatory properties - there must be an entityManagerFactory.
      protected voiddoWrite​(javax.persistence.EntityManager entityManager, java.util.List<? extends T> items)
      Do perform the actual write operation.
      voidsetEntityManagerFactory​(javax.persistence.EntityManagerFactory entityManagerFactory)
      Set the EntityManager to be used internally.
      voidwrite​(java.util.List<? extends T> items)
      Merge all provided items that aren't already in the persistence context and then flush the entity manager.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • logger

        protected static final org.apache.commons.logging.Log logger
    • 方法详细资料

      • setEntityManagerFactory

        public void setEntityManagerFactory​(javax.persistence.EntityManagerFactory entityManagerFactory)
        Set the EntityManager to be used internally.
        参数:
        entityManagerFactory - the entityManagerFactory to set
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Check mandatory properties - there must be an entityManagerFactory.
        指定者:
        afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBean
        抛出:
        java.lang.Exception
      • write

        public void write​(java.util.List<? extends T> items)
        Merge all provided items that aren't already in the persistence context and then flush the entity manager.
        指定者:
        write 在接口中 ItemWriter<T>
        参数:
        items - items to be written
        另请参阅:
        ItemWriter.write(java.util.List)
      • doWrite

        protected void doWrite​(javax.persistence.EntityManager entityManager,
                               java.util.List<? extends T> items)
        Do perform the actual write operation. This can be overridden in a subclass if necessary.
        参数:
        entityManager - the EntityManager to use for the operation
        items - the list of items to use for the write