Class HibernateItemWriter<T>

java.lang.Object
org.springframework.batch.item.database.HibernateItemWriter<T>
All Implemented Interfaces:
ItemWriter<T>, org.springframework.beans.factory.InitializingBean

@Deprecated(since="5.0", forRemoval=true) public class HibernateItemWriter<T> extends Object implements ItemWriter<T>, org.springframework.beans.factory.InitializingBean
Deprecated, for removal: This API element is subject to removal in a future version.
since 5.0 for removal in 5.2. Use the JpaItemWriter instead.
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.
Author:
Dave Syer, Thomas Risberg, Michael Minella, Mahmoud Ben Hassine
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.apache.commons.logging.Log
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Check mandatory properties - there must be a sessionFactory.
    protected void
    doWrite(org.hibernate.SessionFactory sessionFactory, Chunk<? extends T> items)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Do perform the actual write operation using Hibernate's API.
    void
    setClearSession(boolean clearSession)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Flag to indicate that the session should be cleared and flushed at the end of the write (default true).
    void
    setSessionFactory(org.hibernate.SessionFactory sessionFactory)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the Hibernate SessionFactory to be used internally.
    void
    write(Chunk<? extends T> items)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Save or update any entities not in the current hibernate session and then flush the hibernate session.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected static final org.apache.commons.logging.Log logger
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • HibernateItemWriter

      public HibernateItemWriter()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • setClearSession

      public void setClearSession(boolean clearSession)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Flag to indicate that the session should be cleared and flushed at the end of the write (default true).
      Parameters:
      clearSession - the flag value to set
    • setSessionFactory

      public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the Hibernate SessionFactory to be used internally.
      Parameters:
      sessionFactory - session factory to be used by the writer
    • afterPropertiesSet

      public void afterPropertiesSet()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Check mandatory properties - there must be a sessionFactory.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • write

      public void write(Chunk<? extends T> items)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Save or update any entities not in the current hibernate session and then flush the hibernate session.
      Specified by:
      write in interface ItemWriter<T>
      Parameters:
      items - of items to be written. Must not be null.
      See Also:
    • doWrite

      protected void doWrite(org.hibernate.SessionFactory sessionFactory, Chunk<? extends T> items)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Do perform the actual write operation using Hibernate's API. This can be overridden in a subclass if necessary.
      Parameters:
      sessionFactory - Hibernate SessionFactory to be used
      items - the list of items to use for the write