Class FilterJpaUtils

java.lang.Object
ubic.gemma.persistence.util.FilterJpaUtils

public class FilterJpaUtils extends Object
JPA Criteria equivalent of 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 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 JPA Predicate from a Filters (a conjunction of disjunctions).

      Returns CriteriaBuilder.conjunction() (an always-true predicate) when filters is null or empty.

      Parameters:
      cb - criteria builder.
      query - the enclosing AbstractQuery (a CriteriaQuery or Subquery); used to create JPA subqueries for inSubquery / notInSubquery filters. May be null if 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 of formRestrictionClause(CriteriaBuilder, CommonAbstractCriteria, Root, Filters) that honours a registered objectAlias → dotted-prefix map so alias-prefixed paths (e.g. Filter(objectAlias="bc", propertyName="value") where bc was registered with prefix baselineGroup.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.
      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 given objectAlias was 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, so AbstractCriteriaFilteringVoEnabledDao threads the alias → prefix map (sourced from AbstractFilteringVoEnabledDao.getFilterablePropertyObjectAliases()) through to this helper. When the alias is recognised, the registered prefix is walked first (creating implicit joins via Path.get), then the leaf property name is walked on top.