Class AbstractQueryFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- java.lang.Object
-
- ubic.gemma.persistence.service.AbstractDao<O>
-
- ubic.gemma.persistence.service.AbstractVoEnabledDao<O,VO>
-
- ubic.gemma.persistence.service.AbstractFilteringVoEnabledDao<O,VO>
-
- ubic.gemma.persistence.service.AbstractQueryFilteringVoEnabledDao<O,VO>
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
,BaseDao<O>
,BaseVoEnabledDao<O,VO>
,CachedFilteringDao<O>
,CachedFilteringVoEnabledDao<O,VO>
,FilteringDao<O>
,FilteringVoEnabledDao<O,VO>
- Direct Known Subclasses:
AbstractCuratableDao
,CompositeSequenceDaoImpl
,GeneDaoImpl
,TaxonDaoImpl
public abstract class AbstractQueryFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>> extends AbstractFilteringVoEnabledDao<O,VO> implements CachedFilteringVoEnabledDao<O,VO>
Partial implementation ofFilteringVoEnabledDao
based on the HibernateQuery
API.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ubic.gemma.persistence.service.AbstractFilteringVoEnabledDao
AbstractFilteringVoEnabledDao.FilterablePropertiesConfigurer, AbstractFilteringVoEnabledDao.FilterablePropertyMeta
-
-
Field Summary
-
Fields inherited from class ubic.gemma.persistence.service.AbstractVoEnabledDao
REPORT_SLOW_QUERY_AFTER_MS
-
Fields inherited from class ubic.gemma.persistence.service.AbstractDao
elementClass, log
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractQueryFilteringVoEnabledDao(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
count(Filters filters)
Count VOs matching the given filters.long
countWithCache(Filters filters)
protected TypedResultTransformer<O>
getEntityTransformer()
Obtain an entity transformer for the results ofgetFilteringQuery(Filters, Sort)
.protected Query
getFilteringCountQuery(Filters filters)
Produce a query that will be used to retrieve the size ofgetFilteringQuery(Filters, Sort)
.protected Query
getFilteringIdQuery(Filters filters, Sort sort)
Produce a query that will be used to retrieve IDs ofgetFilteringQuery(Filters, Sort)
.protected abstract Query
getFilteringQuery(Filters filters, Sort sort)
Produce a query for retrieving value objects after applying a set of filters and a given ordering.protected TypedResultTransformer<VO>
getValueObjectTransformer()
Obtain a value object transformer for the results ofgetFilteringQuery(Filters, Sort)
.protected abstract void
initializeCachedFilteringResult(O cachedEntity)
Initialize a result fromgetFilteringQuery(Filters, Sort)
retrieved from the HibernateStandardQueryCache
.List<O>
load(Filters filters, Sort sort)
Load entities matching the given filters.Slice<O>
load(Filters filters, Sort sort, int offset, int limit)
Load a slice of entities matching the given filters.List<Long>
loadIds(Filters filters, Sort sort)
Load IDs of entities matching the given filters.List<Long>
loadIdsWithCache(Filters filters, Sort sort)
List<VO>
loadValueObjects(Filters filters, Sort sort)
Load VOs with minimal ordering and filtering.Slice<VO>
loadValueObjects(Filters filters, Sort sort, int offset, int limit)
Load VOs with ordering, filtering and offset/limit.List<VO>
loadValueObjectsWithCache(Filters filters, Sort sort)
Slice<VO>
loadValueObjectsWithCache(Filters filters, Sort sort, int offset, int limit)
List<O>
loadWithCache(Filters filters, Sort sort)
Slice<O>
loadWithCache(Filters filters, Sort sort, int offset, int limit)
-
Methods inherited from class ubic.gemma.persistence.service.AbstractFilteringVoEnabledDao
afterPropertiesSet, configureFilterableProperties, getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilterableProperties, getFilterablePropertyAllowedValues, getFilterablePropertyDescription, getFilterablePropertyIsUsingSubquery, getFilterablePropertyMeta, getFilterablePropertyMeta, getFilterablePropertyType, getSort
-
Methods inherited from class ubic.gemma.persistence.service.AbstractVoEnabledDao
doLoadValueObject, doLoadValueObjects, loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIds, postProcessValueObjects
-
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, remove, remove, remove, save, save, 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, remove, remove, remove, save, save, update, update
-
Methods inherited from interface ubic.gemma.persistence.service.BaseVoEnabledDao
loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIds
-
Methods inherited from interface ubic.gemma.persistence.service.FilteringDao
getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilterableProperties, getFilterablePropertyAllowedValues, getFilterablePropertyDescription, getFilterablePropertyIsUsingSubquery, getFilterablePropertyType, getSort
-
-
-
-
Constructor Detail
-
AbstractQueryFilteringVoEnabledDao
protected AbstractQueryFilteringVoEnabledDao(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory)
-
-
Method Detail
-
getFilteringQuery
protected abstract Query getFilteringQuery(@Nullable Filters filters, @Nullable Sort sort)
Produce a query for retrieving value objects after applying a set of filters and a given ordering.Note that if your implementation does not produce a
List
ofAbstractQueryFilteringVoEnabledDao
whenQuery.list()
is invoked, you must overridegetValueObjectTransformer()
.The make the cached query (i.e.
loadWithCache(Filters, Sort)
behave the same, you also have to explicitly initialize any lazy relations inAbstractVoEnabledDao.doLoadValueObject(Identifiable)
because the VO constructor will not initialize them.- Returns:
- a
Query
that produce a list ofAbstractQueryFilteringVoEnabledDao
-
initializeCachedFilteringResult
protected abstract void initializeCachedFilteringResult(O cachedEntity)
Initialize a result fromgetFilteringQuery(Filters, Sort)
retrieved from the HibernateStandardQueryCache
.Lazy-loaded relations that are fetched in
getFilteringQuery(Filters, Sort)
must be initialized manually in this method to ensure that the entity has all the expected fields if they are retrieved from the second-level cache.
-
getFilteringIdQuery
protected Query getFilteringIdQuery(@Nullable Filters filters, @Nullable Sort sort)
Produce a query that will be used to retrieve IDs ofgetFilteringQuery(Filters, Sort)
.
-
getFilteringCountQuery
protected Query getFilteringCountQuery(@Nullable Filters filters)
Produce a query that will be used to retrieve the size ofgetFilteringQuery(Filters, Sort)
.
-
getEntityTransformer
protected TypedResultTransformer<O> getEntityTransformer()
Obtain an entity transformer for the results ofgetFilteringQuery(Filters, Sort)
.The default entity transformer simply returns the first element of the tuple and omit null values.
-
getValueObjectTransformer
protected TypedResultTransformer<VO> getValueObjectTransformer()
Obtain a value object transformer for the results ofgetFilteringQuery(Filters, Sort)
.By default, it will process the first element of the tuple with
AbstractVoEnabledDao.doLoadValueObjects(Collection)
and then post-process the resulting VOs withAbstractVoEnabledDao.postProcessValueObjects(List)
.
-
loadIds
public List<Long> loadIds(@Nullable Filters filters, @Nullable Sort sort)
Description copied from interface:FilteringDao
Load IDs of entities matching the given filters.- Specified by:
loadIds
in interfaceFilteringDao<O extends Identifiable>
-
loadIdsWithCache
public List<Long> loadIdsWithCache(@Nullable Filters filters, @Nullable Sort sort)
- Specified by:
loadIdsWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
FilteringDao.loadIds(Filters, Sort)
-
load
public List<O> load(@Nullable Filters filters, @Nullable Sort sort)
Description copied from interface:FilteringDao
Load entities matching the given filters.- Specified by:
load
in interfaceFilteringDao<O extends Identifiable>
-
loadWithCache
public Slice<O> loadWithCache(@Nullable Filters filters, @Nullable Sort sort, int offset, int limit)
- Specified by:
loadWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
FilteringDao.load(Filters, Sort, int, int)
-
load
public Slice<O> load(@Nullable Filters filters, @Nullable Sort sort, int offset, int limit)
Description copied from interface:FilteringDao
Load a slice of entities matching the given filters.- Specified by:
load
in interfaceFilteringDao<O extends Identifiable>
-
loadWithCache
public List<O> loadWithCache(@Nullable Filters filters, @Nullable Sort sort)
- Specified by:
loadWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
FilteringDao.load(Filters, Sort)
-
loadValueObjects
public Slice<VO> loadValueObjects(@Nullable Filters filters, @Nullable Sort sort, int offset, int limit)
Description copied from interface:FilteringVoEnabledDao
Load VOs with ordering, filtering and offset/limit.Consider using
FilteringDao.getFilter(String, Filter.Operator, String)
andFilteringDao.getSort(String, Sort.Direction, Sort.NullMode)
to produce the filters and sort safely from user input.- Specified by:
loadValueObjects
in interfaceFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- Parameters:
filters
- filters applied on the search. The properties mentioned in theFilter
must exist and be visible to Hibernate. You can use nested properties such as "curationDetails.lastUpdated".sort
- an object property and direction to order by. This property must exist and be visible to Hibernate. You can use nested properties such as "curationDetails.lastUpdated".offset
- an offset from which entities are retrieved when sorted according to the sort argument, or 0 to ignorelimit
- a limit on the number of returned results, or -1 to ignore- Returns:
- a slice of the relevant data
- See Also:
FilteringDao.load(Filters, Sort, int, int)
-
loadValueObjectsWithCache
public Slice<VO> loadValueObjectsWithCache(@Nullable Filters filters, @Nullable Sort sort, int offset, int limit)
- Specified by:
loadValueObjectsWithCache
in interfaceCachedFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
-
loadValueObjects
public List<VO> loadValueObjects(@Nullable Filters filters, @Nullable Sort sort)
Description copied from interface:FilteringVoEnabledDao
Load VOs with minimal ordering and filtering.Use this as an alternative to
FilteringVoEnabledDao.loadValueObjects(Filters, Sort, int, int)
if you do not intend to provide pagination capabilities.- Specified by:
loadValueObjects
in interfaceFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- See Also:
FilteringDao.load(Filters, Sort)
,FilteringVoEnabledDao.loadValueObjects(Filters, Sort, int, int)
-
loadValueObjectsWithCache
public List<VO> loadValueObjectsWithCache(@Nullable Filters filters, @Nullable Sort sort)
- Specified by:
loadValueObjectsWithCache
in interfaceCachedFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
-
count
public long count(@Nullable Filters filters)
Description copied from interface:FilteringDao
Count VOs matching the given filters.- Specified by:
count
in interfaceFilteringDao<O extends Identifiable>
-
countWithCache
public long countWithCache(@Nullable Filters filters)
- Specified by:
countWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
FilteringDao.count(Filters)
-
-