Class FilterJpaUtils
FilterQueryUtils.
Phase 2 replacement for the Hibernate-Criteria-based FilterCriteriaUtils (deleted in
Step 3 along with the rest of the legacy Criteria API). Translates a Filters
conjunction-of-disjunctions into a single Predicate suitable for use with a JPA
CriteriaQuery.
- Author:
- poirigui (Phase 2 port)
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.persistence.criteria.PredicateformRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Root<?> root, Filters filters) Build a JPAPredicatefrom aFilters(a conjunction of disjunctions).static jakarta.persistence.criteria.PredicateformRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Root<?> root, Filters filters, Map<String, String> aliasPrefixes) Variant offormRestrictionClause(CriteriaBuilder, CommonAbstractCriteria, Root, Filters)that honours a registeredobjectAlias → dotted-prefixmap so alias-prefixed paths (e.g.static jakarta.persistence.criteria.PredicateformRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<?> root, Filters filters) Deprecated.static jakarta.persistence.criteria.Path<?> resolvePath(jakarta.persistence.criteria.Root<?> root, String propertyName) Walk a dot-separated property path from the root (e.g.static jakarta.persistence.criteria.Path<?> resolvePathWithAlias(jakarta.persistence.criteria.Root<?> root, String objectAlias, String propertyName, Map<String, String> aliasPrefixes) Walk a dot-separated property path from the root, prepending the dotted prefix that the givenobjectAliaswas registered with (if any).
-
Method Details
-
formRestrictionClause
public static jakarta.persistence.criteria.Predicate formRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, @Nullable jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Root<?> root, @Nullable Filters filters) Build a JPAPredicatefrom aFilters(a conjunction of disjunctions).Returns
CriteriaBuilder.conjunction()(an always-true predicate) whenfiltersisnullor empty.- Parameters:
cb- criteria builder.query- the enclosingAbstractQuery(aCriteriaQueryorSubquery); used to create JPA subqueries forinSubquery/notInSubqueryfilters. May benullif the caller is certain no subquery filters will be encountered.root- the root of the outer query the predicate will be attached to.filters- the filters to render.
-
formRestrictionClause
public static jakarta.persistence.criteria.Predicate formRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, @Nullable jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Root<?> root, @Nullable Filters filters, @Nullable Map<String, String> aliasPrefixes) Variant offormRestrictionClause(CriteriaBuilder, CommonAbstractCriteria, Root, Filters)that honours a registeredobjectAlias → dotted-prefixmap so alias-prefixed paths (e.g.Filter(objectAlias="bc", propertyName="value")wherebcwas registered with prefixbaselineGroup.characteristics) resolve via an explicit join on the root. -
formRestrictionClause
@Deprecated public static jakarta.persistence.criteria.Predicate formRestrictionClause(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<?> root, @Nullable Filters filters) Deprecated.preferformRestrictionClause(CriteriaBuilder, CommonAbstractCriteria, Root, Filters)soinSubqueryfilters can resolve.Convenience overload for callers that don't need subquery support (back-compat shim). -
resolvePath
public static jakarta.persistence.criteria.Path<?> resolvePath(jakarta.persistence.criteria.Root<?> root, String propertyName) Walk a dot-separated property path from the root (e.g."taxon.commonName"→root.get("taxon").get("commonName")). -
resolvePathWithAlias
public static jakarta.persistence.criteria.Path<?> resolvePathWithAlias(jakarta.persistence.criteria.Root<?> root, @Nullable String objectAlias, String propertyName, @Nullable Map<String, String> aliasPrefixes) Walk a dot-separated property path from the root, prepending the dotted prefix that the givenobjectAliaswas registered with (if any).Pre-Phase-2 the legacy Hibernate Criteria implementation tracked aliases natively through
Subcriteria; the JPA Criteria port doesn't have a built-in alias-to-join mechanism, soAbstractCriteriaFilteringVoEnabledDaothreads thealias → prefixmap (sourced fromAbstractFilteringVoEnabledDao.getFilterablePropertyObjectAliases()) through to this helper. When the alias is recognised, the registered prefix is walked first (creating implicit joins viaPath.get), then the leaf property name is walked on top.
-
formRestrictionClause(CriteriaBuilder, CommonAbstractCriteria, Root, Filters)soinSubqueryfilters can resolve.