Package ubic.gemma.persistence.persister
Class AbstractPersister
java.lang.Object
ubic.gemma.persistence.persister.AbstractPersister
- All Implemented Interfaces:
Persister
- Direct Known Subclasses:
CommonPersister
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classVarious caches to refer back to not-yet persisted entities (and thus not easily obtainable from the persistence context). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.LogShared logger for all persisters.protected static final intSize if batch to report when persisting multiple entities withdoPersist(Collection, Caches). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdoPersist(Object entity, AbstractPersister.Caches caches) protected final List<?> doPersist(Collection<?> entities, AbstractPersister.Caches caches) protected ObjectdoPersistOrUpdate(Object entity, AbstractPersister.Caches caches) protected SessionFactoryPersist a single object.List<?> persist(Collection<?> col) Persist all the objects in a collection.persistOrUpdate(Object entity) Persist or update a single object.
-
Field Details
-
log
protected static final org.apache.commons.logging.Log logShared logger for all persisters. -
REPORT_BATCH_SIZE
protected static final int REPORT_BATCH_SIZESize if batch to report when persisting multiple entities withdoPersist(Collection, Caches).Implementations can use this to have a consistent batch size when reporting.
- See Also:
-
-
Constructor Details
-
AbstractPersister
public AbstractPersister()
-
-
Method Details
-
persist
Description copied from interface:PersisterPersist 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. -
persistOrUpdate
Description copied from interface:PersisterPersist 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:
persistOrUpdatein interfacePersister- Parameters:
entity- the object- Returns:
- the persistent version of the object.
-
persist
Description copied from interface:PersisterPersist 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. -
getSessionFactory
-
doPersist
@OverridingMethodsMustInvokeSuper protected Object doPersist(Object entity, AbstractPersister.Caches caches) -
doPersist
-
doPersistOrUpdate
@OverridingMethodsMustInvokeSuper protected Object doPersistOrUpdate(Object entity, AbstractPersister.Caches caches)
-