Package org.n52.series.db.old.dao
Class AbstractDao<T>
java.lang.Object
org.n52.series.db.old.dao.AbstractDao<T>
- All Implemented Interfaces:
GenericDao<T,Long>
- Direct Known Subclasses:
DataDao,DatasetDao,MeasuringProgramDao,ParameterDao,RelatedFeatureDao,SamplingDao
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.hibernate.Sessionprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDefaultOrder(jakarta.persistence.criteria.CriteriaQuery<?> cq, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<?> root, Class<?> clazz) protected jakarta.persistence.criteria.Root<T>applyFetchModes(jakarta.persistence.criteria.Root<T> root, DbQuery query, boolean instance) Hook for subclasses to eagerly fetch associations via JPA fetch joins.protected voidapplyLimitOffset(jakarta.persistence.TypedQuery<?> typedQuery, DbQuery query) protected DbQueryprotected longorg.springframework.data.jpa.domain.Specification<org.n52.series.db.beans.DatasetEntity>createLastValuesFilter(DbQuery query) protected org.springframework.data.jpa.domain.Specification<T>datasetFilter(DbQuery query) protected org.springframework.data.jpa.domain.Specification<T>datasetFilter(DbQuery query, boolean withRequestFilters) protected booleanprotected TfindFirst(org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Sort sort, DbQuery query, boolean instance) Returns the first entity matchingspecin the given order, or null.protected TfindUnique(org.springframework.data.jpa.domain.Specification<T> spec, DbQuery query, boolean instance) protected abstract Stringprotected Stringorg.springframework.data.jpa.domain.Specification<T>getDefaultSpecification(DbQuery query) org.springframework.data.jpa.domain.Specification<T>getDefaultSpecification(DbQuery query, boolean withRequestFilters) protected StringgetFetchPath(String... values) getInstance(Long key, DbQuery query) getInstance(String key, DbQuery query) protected TgetInstance(String key, DbQuery query, Class<T> clazz) booleanhasInstance(Long id, DbQuery query) booleanhasInstance(Long id, DbQuery query, Class<?> clazz) booleanhasInstance(String id, DbQuery query) org.springframework.data.jpa.domain.Specification<T>hasMatchingDataset(DbQuery dbQuery) Builds a correlatedEXISTSsubquery overDatasetEntitythat applies the full set ofdataset filtersand correlates the matching datasets back to the current root viagetDatasetProperty().org.springframework.data.jpa.domain.Specification<T>hasMatchingDataset(DbQuery dbQuery, boolean withRequestFilters) AshasMatchingDataset(DbQuery), optionally also restricting the subquery's datasets with thedatasets=andsamplings=request filters (DbQuery.datasetAndSamplingRestrictions(jakarta.persistence.criteria.From<org.n52.series.db.beans.DatasetEntity, ?>, jakarta.persistence.criteria.CriteriaBuilder, jakarta.persistence.EntityManager)).protected <I extends org.n52.series.db.beans.i18n.I18nEntity<?>>
org.springframework.data.jpa.domain.Specification<T>protected <I extends org.n52.series.db.beans.i18n.I18nEntity<?>>
org.springframework.data.jpa.domain.Specification<T>protected org.springframework.data.jpa.domain.Specification<T>protected org.springframework.data.jpa.domain.Specification<T>matchIdOrDomainId(String key, DbQuery query) toStringList(Collection<Long> set) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.n52.series.db.old.dao.GenericDao
getAllInstances
-
Field Details
-
TRANSLATIONS_ALIAS
- See Also:
-
session
protected final org.hibernate.Session session
-
-
Constructor Details
-
AbstractDao
public AbstractDao(org.hibernate.Session session)
-
-
Method Details
-
getEntityClass
-
getDatasetProperty
-
getDefaultAlias
-
findAll
-
findFirst
protected T findFirst(org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Sort sort, DbQuery query, boolean instance) Returns the first entity matchingspecin the given order, or null. Ordering plussetMaxResults(1)is what lets callers express "the closest/newest match" with a plainSpecification, instead of the correlated max/min subqueries the legacy Criteria API needed.- Parameters:
spec- the restriction to apply, may be nullsort- the order deciding which match winsquery- the query to apply fetch modes forinstance- whether fetch modes apply to a single instance- Returns:
- the first match or null
-
findUnique
-
count
-
exists
-
applyLimitOffset
-
hasInstance
-
hasInstance
- Specified by:
hasInstancein interfaceGenericDao<T,Long>
-
hasInstance
-
getInstance
-
getInstance
- Specified by:
getInstancein interfaceGenericDao<T,Long>
-
getInstance
-
matchIdOrDomainId
-
matchId
-
getCount
- Specified by:
getCountin interfaceGenericDao<T,Long>
-
i18nSpec
-
i18nSpec
-
getDefaultSpecification
-
getDefaultSpecification
public org.springframework.data.jpa.domain.Specification<T> getDefaultSpecification(DbQuery query, boolean withRequestFilters) - Parameters:
query- the query parameterswithRequestFilters-trueto also apply thedatasets=andsamplings=request filters (DbQuery.datasetAndSamplingRestrictions(jakarta.persistence.criteria.From<org.n52.series.db.beans.DatasetEntity, ?>, jakarta.persistence.criteria.CriteriaBuilder, jakarta.persistence.EntityManager)) inside the dataset subquery, as the legacyquery.addFilters(...)did- Returns:
- the default specification
-
datasetFilter
-
datasetFilter
-
addDefaultOrder
protected void addDefaultOrder(jakarta.persistence.criteria.CriteriaQuery<?> cq, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<?> root, Class<?> clazz) -
hasMatchingDataset
Builds a correlatedEXISTSsubquery overDatasetEntitythat applies the full set ofdataset filtersand correlates the matching datasets back to the current root viagetDatasetProperty().- Parameters:
dbQuery- the query parameters- Returns:
- a specification restricting the root to entities referenced by a matching dataset
-
hasMatchingDataset
public org.springframework.data.jpa.domain.Specification<T> hasMatchingDataset(DbQuery dbQuery, boolean withRequestFilters) AshasMatchingDataset(DbQuery), optionally also restricting the subquery's datasets with thedatasets=andsamplings=request filters (DbQuery.datasetAndSamplingRestrictions(jakarta.persistence.criteria.From<org.n52.series.db.beans.DatasetEntity, ?>, jakarta.persistence.criteria.CriteriaBuilder, jakarta.persistence.EntityManager)). The other dataset filters are already covered bymatchFilters().- Parameters:
dbQuery- the query parameterswithRequestFilters-trueto apply the request's dataset filters inside the subquery- Returns:
- a specification restricting the root to entities referenced by a matching dataset
-
createLastValuesFilter
public org.springframework.data.jpa.domain.Specification<org.n52.series.db.beans.DatasetEntity> createLastValuesFilter(DbQuery query) -
checkLevelParameterForHierarchyQuery
-
toStringList
-
applyFetchModes
protected jakarta.persistence.criteria.Root<T> applyFetchModes(jakarta.persistence.criteria.Root<T> root, DbQuery query, boolean instance) Hook for subclasses to eagerly fetch associations via JPA fetch joins. The base implementation is a no-op.- Parameters:
root- the query rootquery- the query parametersinstance-truewhen fetching a single instance (expanded view)- Returns:
- the (possibly fetch-augmented) root
-
getFetchPath
-
get
- Parameters:
query- Query parameters- Returns:
- the result
-