Class JpaCriteriaUtils
java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.support.JpaCriteriaUtils
Support class with convenience methods for criteria-building functionality common to custom JPA
repository implementations.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.persistence.criteria.PredicatebuildNonProductionTrackingLevelFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) Builds aPredicatefor non-production tracking level.static jakarta.persistence.criteria.PredicatebuildNotArchivedFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) static jakarta.persistence.criteria.PredicatebuildNotSandboxArchivedFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) Sandbox-archived records are considered fully obsolete by the system and should never be included in query results.static jakarta.persistence.criteria.PredicatebuildTenantIdFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) static jakarta.persistence.criteria.PredicategetSortingCriteria(boolean isSorted, jakarta.persistence.criteria.Root<?> root, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Creates a filter that restricts results to only include entities whoseSortable.getSorted()has the given value.static StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Method Details
-
getSortingCriteria
public static jakarta.persistence.criteria.Predicate getSortingCriteria(boolean isSorted, jakarta.persistence.criteria.Root<?> root, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Creates a filter that restricts results to only include entities whoseSortable.getSorted()has the given value. This is implemented by creating criteria based around the value ofSortable.getSorting().- Parameters:
isSorted- the criteria created will restrict results to only include entities whoseSortable.getSorted()has the given valueroot- the root entity on which the query will be performedcriteriaBuilder- the criteria builder used to generate parameters/predicatesparameterValues- a map of parameter names to argument values that will be used to run the query. Any parameter values required to perform the query should be added to this map.- Returns:
- a criteria that restricts results to only include entities whose
Sortable.getSorted()has the given value
-
buildNonProductionTrackingLevelFilter
public static jakarta.persistence.criteria.Predicate buildNonProductionTrackingLevelFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) Builds aPredicatefor non-production tracking level. -
buildTenantIdFilter
public static jakarta.persistence.criteria.Predicate buildTenantIdFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildNotArchivedFilter
public static jakarta.persistence.criteria.Predicate buildNotArchivedFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) -
buildNotSandboxArchivedFilter
public static jakarta.persistence.criteria.Predicate buildNotSandboxArchivedFilter(jakarta.persistence.criteria.Root<?> entity, jakarta.persistence.criteria.CriteriaBuilder builder) Sandbox-archived records are considered fully obsolete by the system and should never be included in query results. This is a filter that can be used to exclude such records.- Parameters:
entity- the trackable entity root being queriedbuilder- criteria builder- Returns:
- a predicate that can be used to exclude sandbox-archived records
- Since:
- Catalog Services 2.3.0, Release Train 2.3.0
-
getTenantIdFromContext
@Nullable public static String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-