Class AbstractQueryFilteringVoEnabledDao<O extends Identifiable,VO extends IdentifiableValueObject<O>>
- 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
FilteringVoEnabledDao
based on the Hibernate Query
API.- Author:
- poirigui
- See Also:
-
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
log
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractQueryFilteringVoEnabledDao
(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionlong
Count VOs matching the given filters.long
countWithCache
(Filters filters) protected TypedResultTransformer
<O> 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> 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
.Load entities matching the given filters.Load a slice of entities matching the given filters.Load IDs of entities matching the given filters.loadIdsWithCache
(Filters filters, Sort sort) loadValueObjects
(Filters filters, Sort sort) Load VOs with minimal ordering and filtering.loadValueObjects
(Filters filters, Sort sort, int offset, int limit) Load VOs with ordering, filtering and offset/limit.loadValueObjectsWithCache
(Filters filters, Sort sort) loadValueObjectsWithCache
(Filters filters, Sort sort, int offset, int limit) loadWithCache
(Filters filters, Sort sort) 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, 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
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 Details
-
AbstractQueryFilteringVoEnabledDao
protected AbstractQueryFilteringVoEnabledDao(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory)
-
-
Method Details
-
getFilteringQuery
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
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
Produce a query that will be used to retrieve IDs ofgetFilteringQuery(Filters, Sort)
. -
getFilteringCountQuery
Produce a query that will be used to retrieve the size ofgetFilteringQuery(Filters, Sort)
. -
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
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
Description copied from interface:FilteringDao
Load IDs of entities matching the given filters.- Specified by:
loadIds
in interfaceFilteringDao<O extends Identifiable>
-
loadIdsWithCache
- Specified by:
loadIdsWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
-
load
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:
-
load
Description copied from interface:FilteringDao
Load a slice of entities matching the given filters.- Specified by:
load
in interfaceFilteringDao<O extends Identifiable>
-
loadWithCache
- Specified by:
loadWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
-
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:
-
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
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:
-
loadValueObjectsWithCache
- Specified by:
loadValueObjectsWithCache
in interfaceCachedFilteringVoEnabledDao<O extends Identifiable,
VO extends IdentifiableValueObject<O>>
-
count
Description copied from interface:FilteringDao
Count VOs matching the given filters.- Specified by:
count
in interfaceFilteringDao<O extends Identifiable>
-
countWithCache
- Specified by:
countWithCache
in interfaceCachedFilteringDao<O extends Identifiable>
- See Also:
-