Class AbstractPersister

java.lang.Object
ubic.gemma.persistence.persister.AbstractPersister
All Implemented Interfaces:
Persister
Direct Known Subclasses:
CommonPersister

public abstract class AbstractPersister extends Object implements Persister
Base class for Persister implementations.

Important note: persisting is a somewhat complicated process, and for some reason we cannot afford to let Hibernate flush changes to the database until the whole operation is completed. This is why we use the FlushMode.MANUAL, manually flush, and we subsequently restore it to the default FlushMode.AUTO when done.

Author:
pavlidis
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
      Shared logger for all persisters.
    • REPORT_BATCH_SIZE

      protected static final int REPORT_BATCH_SIZE
      Size if batch to report when persisting multiple entities with doPersist(Collection, Caches).

      Implementations can use this to have a consistent batch size when reporting.

      See Also:
  • Constructor Details

    • AbstractPersister

      public AbstractPersister()
  • Method Details

    • persist

      @Transactional public Object persist(Object entity)
      Description copied from interface: Persister
      Persist a single object. Non-nullable dependencies are checked and persisted first, if the reference is detached, or converted into a reference to a persistent object identified by the objects business key. If a matching object already exists, it will not be changed.
      Specified by:
      persist in interface Persister
      Parameters:
      entity - the object
      Returns:
      the persistent version of the object.
    • persistOrUpdate

      @Transactional public Object persistOrUpdate(Object entity)
      Description copied from interface: Persister
      Persist or update a single object. If the object already exists in the system, it will be replaced with the supplied instance. This means that any existing data may be lost. Otherwise a new persistent instance will be created from the supplied instance. Non-nullable dependencies will be replaced with existing persistent ones or created anew: Associated objects will not be updated if they already exist. Therefore this method has limited usefulness: when the provided object has new data but the associated objects are either new or already existing. If you want to update associated objects you must update them explicitly (perhaps with a call to persistOrUpdate on them).
      Specified by:
      persistOrUpdate in interface Persister
      Parameters:
      entity - the object
      Returns:
      the persistent version of the object.
    • persist

      @Transactional public List<?> persist(Collection<?> col)
      Description copied from interface: Persister
      Persist all the objects in a collection. Non-nullable dependencies are checked and persisted first, if the reference is detached, or converted into a reference to a persistent object identified by the objects business key. Matching instances are not changed.
      Specified by:
      persist in interface Persister
      Parameters:
      col - the collection of objects
      Returns:
      The persistent versions of the objects.
    • getSessionFactory

      protected SessionFactory getSessionFactory()
    • doPersist

    • doPersist

      protected final List<?> doPersist(Collection<?> entities, AbstractPersister.Caches caches)
    • doPersistOrUpdate

      @OverridingMethodsMustInvokeSuper protected Object doPersistOrUpdate(Object entity, AbstractPersister.Caches caches)