Package ubic.gemma.persistence.service
Class AbstractVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- java.lang.Object
-
- ubic.gemma.persistence.service.AbstractDao<O>
-
- ubic.gemma.persistence.service.AbstractVoEnabledDao<O,VO>
-
- All Implemented Interfaces:
BaseDao<O>
,BaseVoEnabledDao<O,VO>
- Direct Known Subclasses:
AbstractFilteringVoEnabledDao
,AbstractNoopFilteringVoEnabledDao
,BibliographicReferenceDaoImpl
,BioAssayDimensionDaoImpl
,BioMaterialDaoImpl
,BioSequenceDaoImpl
,BlacklistedEntityDaoImpl
,BlatResultDaoImpl
,ExperimentalFactorDaoImpl
,ExpressionExperimentSetDaoImpl
,GeeqDaoImpl
,GeneProductDaoImpl
public abstract class AbstractVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>> extends AbstractDao<O> implements BaseVoEnabledDao<O,VO>
Created by tesarst on 01/06/17. Base DAO providing value object functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
REPORT_SLOW_QUERY_AFTER_MS
Amount of time in milliseconds after which a query (including post-processing) should be reported.-
Fields inherited from class ubic.gemma.persistence.service.AbstractDao
log
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractVoEnabledDao(Class<? extends O> elementClass, SessionFactory sessionFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract VO
doLoadValueObject(O entity)
Load a value object for a given entity.List<VO>
doLoadValueObjects(Collection<O> entities)
Load all the value objects for the given entities.List<VO>
loadAllValueObjects()
Should be overridden for any entity that requires special handling of larger amounts of VOs.VO
loadValueObject(O entity)
Load a value object corresponding to an entityVO
loadValueObjectById(Long id)
List<VO>
loadValueObjects(Collection<O> entities)
The default implementation callsloadValueObject(Identifiable)
for each entity and filters out nulls.List<VO>
loadValueObjectsByIds(Collection<Long> ids)
protected void
postProcessValueObjects(List<VO> vos)
Post-process VOs in bulk.-
Methods inherited from class ubic.gemma.persistence.service.AbstractDao
countAll, create, create, find, findByProperty, findByPropertyIn, findOneByProperty, findOrCreate, getBatchSize, getElementClass, getIdentifierPropertyName, getSessionFactory, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, remove, save, save, streamAll, streamAll, streamQuery, update, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ubic.gemma.persistence.service.BaseDao
countAll, create, create, find, findOrCreate, getElementClass, getIdentifierPropertyName, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, remove, save, save, streamAll, streamAll, update, update
-
-
-
-
Field Detail
-
REPORT_SLOW_QUERY_AFTER_MS
protected static final int REPORT_SLOW_QUERY_AFTER_MS
Amount of time in milliseconds after which a query (including post-processing) should be reported.If there is no way to perform a given query under this amount of time, consider paginating results or optimizing how Hibernate entities are loaded or cached.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractVoEnabledDao
protected AbstractVoEnabledDao(Class<? extends O> elementClass, SessionFactory sessionFactory)
-
-
Method Detail
-
doLoadValueObject
@Nullable protected abstract VO doLoadValueObject(O entity)
Load a value object for a given entity.This should be fast and efficient, and avoid any database query or post-processing. If you need to perform additional queries, implement
postProcessValueObjects(List)
instead.
-
doLoadValueObjects
public List<VO> doLoadValueObjects(Collection<O> entities)
Load all the value objects for the given entities.The default is to apply
doLoadValueObject(Identifiable)
on each entry and weed out null elements.This method should be fast and any post-processing should happen in
postProcessValueObjects(List)
.
-
postProcessValueObjects
protected void postProcessValueObjects(List<VO> vos)
Post-process VOs in bulk.Use this as an opportunity to load extra informations that could not be populated in the initial
doLoadValueObject(Identifiable)
ordoLoadValueObjects(Collection)
-
loadValueObject
public final VO loadValueObject(O entity)
Description copied from interface:BaseVoEnabledDao
Load a value object corresponding to an entity- Specified by:
loadValueObject
in interfaceBaseVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- Parameters:
entity
- the entity to turn into a value object- Returns:
- a value object
-
loadValueObjectById
public final VO loadValueObjectById(Long id)
- Specified by:
loadValueObjectById
in interfaceBaseVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- Returns:
- a value object, or null if it could not be constructed
-
loadValueObjects
public final List<VO> loadValueObjects(Collection<O> entities)
The default implementation callsloadValueObject(Identifiable)
for each entity and filters out nulls.- Specified by:
loadValueObjects
in interfaceBaseVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- Parameters:
entities
- the entities to turn into value objects- Returns:
- a collection of value objects
-
loadValueObjectsByIds
public final List<VO> loadValueObjectsByIds(Collection<Long> ids)
- Specified by:
loadValueObjectsByIds
in interfaceBaseVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
-
loadAllValueObjects
public final List<VO> loadAllValueObjects()
Should be overridden for any entity that requires special handling of larger amounts of VOs.- Specified by:
loadAllValueObjects
in interfaceBaseVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- Returns:
- VOs of all instances of the class this DAO manages.
-
-