Class JpaDataFeedQueryHelper
java.lang.Object
com.broadleafcommerce.datafeed.provider.jpa.repository.support.JpaDataFeedQueryHelper
Provides commonly useful query functionality.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionOptional<javax.persistence.criteria.Predicate>
buildTenantTrackingAndArchivedFilter
(javax.persistence.criteria.Root<?> trackableRootEntity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String, Object> parameterValues, String trackingTenantIdParamName, javax.persistence.EntityManager entityManager) Similar to logic inJpaNarrowExecutor
.<R> List<R>
createQueryAndGetResultList
(javax.persistence.criteria.CriteriaQuery<R> criteria, javax.persistence.LockModeType lockModeType, Map<String, Object> parameterValues, javax.persistence.EntityManager entityManager) Simplifies the process of creating aTypedQuery
, setting parameters, and getting the results.
-
Constructor Details
-
JpaDataFeedQueryHelper
public JpaDataFeedQueryHelper()
-
-
Method Details
-
buildTenantTrackingAndArchivedFilter
public Optional<javax.persistence.criteria.Predicate> buildTenantTrackingAndArchivedFilter(javax.persistence.criteria.Root<?> trackableRootEntity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String, Object> parameterValues, String trackingTenantIdParamName, javax.persistence.EntityManager entityManager) Similar to logic inJpaNarrowExecutor
. This is useful for queries that can't useJpaNarrowingHelper
due to special configuration requirements such as needing to setTypedQuery.setLockMode(LockModeType)
.- Parameters:
trackableRootEntity
- the query rootcontextInfo
- the context to build the criteria fromparameterValues
- a map of query parameters and their values. Any new parameter will be added to this map.trackingTenantIdParamName
- if a filter is added on tracking tenant ID, this is the name of the parameter that will be used for it and added toparameterValues
entityManager
- the entity manager to use for building criteria- Returns:
- an
Optional
containing any tenant criteria that needs to be applied if applicable
-
createQueryAndGetResultList
public <R> List<R> createQueryAndGetResultList(javax.persistence.criteria.CriteriaQuery<R> criteria, @Nullable javax.persistence.LockModeType lockModeType, Map<String, Object> parameterValues, javax.persistence.EntityManager entityManager) Simplifies the process of creating aTypedQuery
, setting parameters, and getting the results.- Type Parameters:
R
- the result element type- Parameters:
criteria
- the criteria to build the query fromlockModeType
- (optional) the lock mode to set on the queryparameterValues
- query parameter values to set on the queryentityManager
- the entity manager to use- Returns:
- the result list of the query
-