类 HibernateItemWriter<T>

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

    public class HibernateItemWriter<T>
    extends java.lang.Object
    implements ItemWriter<T>, org.springframework.beans.factory.InitializingBean
    ItemWriter that uses a Hibernate session to save or update entities that are not part of the current Hibernate session. It will also flush the session after writing (i.e. at chunk boundaries if used in a Spring Batch TaskletStep). It will also clear the session on write default (see clearSession property).

    The writer is thread-safe once properties are set (normal singleton behavior) if a CurrentSessionContext that uses only one session per thread is used.
    作者:
    Dave Syer, Thomas Risberg, Michael Minella
    • 字段概要

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

      所有方法 实例方法 具体方法 已过时的方法 
      修饰符和类型方法说明
      voidafterPropertiesSet()
      Check mandatory properties - there must be a sessionFactory.
      protected voiddoWrite​(org.hibernate.SessionFactory sessionFactory, java.util.List<? extends T> items)
      Do perform the actual write operation using Hibernate's API.
      protected voiddoWrite​(org.springframework.orm.hibernate5.HibernateOperations hibernateTemplate, java.util.List<? extends T> items)
      已过时。
      As of 2.2 in favor of using Hibernate's session management APIs directly
      voidsetClearSession​(boolean clearSession)
      Flag to indicate that the session should be cleared and flushed at the end of the write (default true).
      voidsetSessionFactory​(org.hibernate.SessionFactory sessionFactory)
      Set the Hibernate SessionFactory to be used internally.
      voidwrite​(java.util.List<? extends T> items)
      Save or update any entities not in the current hibernate session and then flush the hibernate session.
      • 从类继承的方法 java.lang.Object

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

      • logger

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

      • setClearSession

        public void setClearSession​(boolean clearSession)
        Flag to indicate that the session should be cleared and flushed at the end of the write (default true).
        参数:
        clearSession - the flag value to set
      • setSessionFactory

        public void setSessionFactory​(org.hibernate.SessionFactory sessionFactory)
        Set the Hibernate SessionFactory to be used internally.
        参数:
        sessionFactory - session factory to be used by the writer
      • afterPropertiesSet

        public void afterPropertiesSet()
        Check mandatory properties - there must be a sessionFactory.
        指定者:
        afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBean
      • write

        public void write​(java.util.List<? extends T> items)
        Save or update any entities not in the current hibernate session and then flush the hibernate session.
        指定者:
        write 在接口中 ItemWriter<T>
        参数:
        items - items to be written
        另请参阅:
        ItemWriter.write(java.util.List)
      • doWrite

        protected void doWrite​(org.hibernate.SessionFactory sessionFactory,
                               java.util.List<? extends T> items)
        Do perform the actual write operation using Hibernate's API. This can be overridden in a subclass if necessary.
        参数:
        sessionFactory - Hibernate SessionFactory to be used
        items - the list of items to use for the write
      • doWrite

        @Deprecated
        protected void doWrite​(org.springframework.orm.hibernate5.HibernateOperations hibernateTemplate,
                               java.util.List<? extends T> items)
        已过时。
        As of 2.2 in favor of using Hibernate's session management APIs directly
        Do perform the actual write operation using HibernateOperations. This can be overridden in a subclass if necessary.
        参数:
        hibernateTemplate - the HibernateTemplate to use for the operation
        items - the list of items to use for the write