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 Hibernate Query.- Author:
- poirigui
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractFilteringVoEnabledDao
AbstractFilteringVoEnabledDao.FilterablePropertiesConfigurer, AbstractFilteringVoEnabledDao.FilterablePropertyMetaNested classes/interfaces inherited from interface FilteringDao
FilteringDao.ConjunctSpec -
Field Summary
Fields inherited from class AbstractVoEnabledDao
REPORT_SLOW_QUERY_AFTER_MSFields inherited from class AbstractDao
log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractQueryFilteringVoEnabledDao(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionlongCount VOs matching the given filters.longcountWithCache(Filters filters) protected TypedResultTransformer<O> protected org.hibernate.query.Query<?> getFilteringCountQuery(Filters filters) protected org.hibernate.query.Query<?> getFilteringIdQuery(Filters filters, Sort sort) protected abstract org.hibernate.query.Query<?> getFilteringQuery(Filters filters, Sort sort) Produce a query for retrieving filtered entities or VOs after applying filters and ordering.protected StringName of the Hibernate L2 query-cache region to use for filtered-VO queries from this DAO, ornullto use Hibernate's defaultStandardQueryCacheregion.protected TypedResultTransformer<VO> protected abstract voidinitializeCachedFilteringResult(O cachedEntity) Initialize a result fromgetFilteringQuery(Filters, Sort)retrieved from cache.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.loadValueObjectsByCursor(Filters filters, Sort sort, Cursor cursor, int limit) Load VOs by keyset (cursor) pagination.loadValueObjectsByCursorWithCache(Filters filters, Sort sort, Cursor cursor, int limit) Cursor-paged sister ofloadValueObjectsWithCache(Filters, Sort, int, int).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 AbstractFilteringVoEnabledDao
afterPropertiesSet, configureFilterableProperties, getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilterableProperties, getFilterablePropertyAllowedValues, getFilterablePropertyDescription, getFilterablePropertyMeta, getFilterablePropertyObjectAliases, getFilterablePropertyType, getObjectAlias, getSort, isFilterablePropertyDeprecated, isFilterablePropertyUsingSubquery, resolveFilterablePropertyMeta, resolveFilterablePropertyMetaMethods inherited from class AbstractVoEnabledDao
doLoadValueObject, doLoadValueObjects, loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIds, postProcessValueObjectsMethods inherited from class AbstractDao
countAll, create, create, find, findByProperty, findByPropertyIn, findIdByProperty, findOneByProperty, findOrCreate, getBatchSize, getElementClass, getEntityName, getIdentifierPropertyName, getSessionFactory, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, save, save, streamAll, streamAll, streamQuery, update, updateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseDao
countAll, create, create, find, findOrCreate, getElementClass, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, save, save, streamAll, streamAll, update, updateMethods inherited from interface BaseVoEnabledDao
loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIdsMethods inherited from interface FilteringDao
getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilter, getFilterableProperties, getFilterablePropertyAllowedValues, getFilterablePropertyDescription, getFilterablePropertyType, getSort, isFilterablePropertyDeprecated, isFilterablePropertyUsingSubquery
-
Constructor Details
-
AbstractQueryFilteringVoEnabledDao
protected AbstractQueryFilteringVoEnabledDao(String objectAlias, Class<O> elementClass, SessionFactory sessionFactory)
-
-
Method Details
-
getFilteringQuery
protected abstract org.hibernate.query.Query<?> getFilteringQuery(@Nullable Filters filters, @Nullable Sort sort) Produce a query for retrieving filtered entities or VOs after applying filters and ordering.The query is expected to return a
ListofO. Implementations that return tuples should also overridegetValueObjectTransformer(). -
initializeCachedFilteringResult
Initialize a result fromgetFilteringQuery(Filters, Sort)retrieved from cache. Lazy-loaded relations fetched by the filtering query must be initialized here so that VOs populated from the second-level cache have the expected fields. -
getFilteringIdQuery
-
getFilteringCountQuery
-
getQueryCacheRegion
Name of the Hibernate L2 query-cache region to use for filtered-VO queries from this DAO, ornullto use Hibernate's defaultStandardQueryCacheregion.Subclasses with a hot filter path (e.g.
ExpressionExperimentDaoImpl) override this to shard their cache entries into a dedicated, separately-bounded region declared inEhcacheConfig. Shared sharding here is safe because each subclass'sgetFilteringQuery(Filters, Sort)already produces type-specific HQL — there is no risk of two DAO types colliding on the same cache key.Default:
null(fall back toStandardQueryCache). SeeHIBERNATE_L2_CACHE_AUDIT.mdrecommendation #4 for context. -
getEntityTransformer
-
getValueObjectTransformer
-
loadIds
Description copied from interface:FilteringDaoLoad IDs of entities matching the given filters.- Specified by:
loadIdsin interfaceFilteringDao<O extends Identifiable>
-
loadIdsWithCache
- Specified by:
loadIdsWithCachein interfaceCachedFilteringDao<O extends Identifiable>- See Also:
-
load
Description copied from interface:FilteringDaoLoad entities matching the given filters.- Specified by:
loadin interfaceFilteringDao<O extends Identifiable>
-
loadWithCache
public Slice<O> loadWithCache(@Nullable Filters filters, @Nullable Sort sort, int offset, int limit) - Specified by:
loadWithCachein interfaceCachedFilteringDao<O extends Identifiable>- See Also:
-
load
Description copied from interface:FilteringDaoLoad a slice of entities matching the given filters.- Specified by:
loadin interfaceFilteringDao<O extends Identifiable>
-
loadWithCache
- Specified by:
loadWithCachein 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:FilteringVoEnabledDaoLoad 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:
loadValueObjectsin interfaceFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>- Parameters:
filters- filters applied on the search. The properties mentioned in theFiltermust 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:
loadValueObjectsWithCachein interfaceCachedFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>
-
loadValueObjects
Description copied from interface:FilteringVoEnabledDaoLoad 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:
loadValueObjectsin interfaceFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>- See Also:
-
loadValueObjectsWithCache
- Specified by:
loadValueObjectsWithCachein interfaceCachedFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>
-
loadValueObjectsByCursor
public CursorPage<VO> loadValueObjectsByCursor(@Nullable Filters filters, Sort sort, @Nullable Cursor cursor, int limit) Description copied from interface:FilteringVoEnabledDaoLoad VOs by keyset (cursor) pagination.Cursor pagination avoids the O(N) scan-and-discard cost of
FilteringVoEnabledDao.loadValueObjects(Filters, Sort, int, int)on deep pages and is drift-resistant under concurrent inserts (a row inserted into the middle of the sorted order between two page requests will not produce duplicates or skips at the page boundary).Sort requirements. The resolved
Sortmust be deterministic, i.e. it must end with a unique key (typically the identifier property). Initial support is limited to a single sort component on the identifier property (+id/-id); compound sorts are intentionally rejected until the index audit (recce §5.1) has been completed for the sorting columns of interest.When
cursorisnull, the page returned is the first page in the sort order, with a non-nullCursorPage.getNextCursor()if more rows exist.- Specified by:
loadValueObjectsByCursorin interfaceFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>- Parameters:
filters- filters applied on the search; same shape asFilteringVoEnabledDao.loadValueObjects(Filters, Sort, int, int)sort- deterministic sort (must end in a unique key); must not benullfor cursor modecursor- the cursor token decoded from a previous response, ornullto fetch the first pagelimit- page size; the implementation fetches one additional row internally to detect whether a next page exists, but the returned page contains at mostlimitrows- Returns:
- a
CursorPagewith the rows, thenextCursor(ornullat the end of the collection),prevCursor(when known), and atotalElementsofnull(cursor mode does not count by default)
-
loadValueObjectsByCursorWithCache
public CursorPage<VO> loadValueObjectsByCursorWithCache(@Nullable Filters filters, Sort sort, @Nullable Cursor cursor, int limit) Cursor-paged sister ofloadValueObjectsWithCache(Filters, Sort, int, int). -
count
Description copied from interface:FilteringDaoCount VOs matching the given filters.- Specified by:
countin interfaceFilteringDao<O extends Identifiable>
-
countWithCache
- Specified by:
countWithCachein interfaceCachedFilteringDao<O extends Identifiable>- See Also:
-