Class NarrowingPartTreeJpaQuery
- java.lang.Object
-
- org.springframework.data.jpa.repository.query.AbstractJpaQuery
-
- com.broadleafcommerce.data.tracking.jpa.filtering.narrow.dynamic.NarrowingPartTreeJpaQuery
-
- All Implemented Interfaces:
QueryPreparer
,org.springframework.data.repository.query.RepositoryQuery
public class NarrowingPartTreeJpaQuery extends org.springframework.data.jpa.repository.query.AbstractJpaQuery implements QueryPreparer
Customized version ofPartTreeJpaQuery
to support special filtering of results from a repository query method. This is responsible for calling aNarrowExecutor
implementation in order to perform the requested query (possibly with enhancements) and return filtered results.- Author:
- Jeff Fischer
- See Also:
TrackableRepository
,Narrow
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCESSOR
static String
PARAMETER_BINDER
static String
QUERY_PREPARER
-
Constructor Summary
Constructors Constructor Description NarrowingPartTreeJpaQuery(org.springframework.data.jpa.repository.query.JpaQueryMethod method, javax.persistence.EntityManager em, org.springframework.data.jpa.provider.PersistenceProvider persistenceProvider, org.springframework.data.jpa.repository.query.EscapeCharacter escape, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, RSQLVisitorHolder<?> rsqlVisitorHolder, JpaFiltersCriteriaBuilder catalogFiltersCriteriaBuilder, org.springframework.data.repository.core.RepositoryMetadata repositoryMetadata, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <D> void
addSorting(javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.CriteriaBuilder cb, Class<D> type)
Apply any declared sort stipulations on the query.protected javax.persistence.Query
applyEntityGraphConfig(javax.persistence.Query query, org.springframework.data.jpa.repository.query.JpaQueryMethod method)
Apply any declared entity graph stipulations on the query.protected javax.persistence.Query
applyHints(javax.persistence.Query query, org.springframework.data.jpa.repository.query.JpaQueryMethod method)
Apply any declared Jpa hint stipulations on the query.protected javax.persistence.Query
bindAndPrepare(org.springframework.data.jpa.repository.query.ParameterBinder binder, javax.persistence.Query query, Object metadata, org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
Execute the binding of method params on the queryprotected javax.persistence.Query
doCreateCountQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
protected javax.persistence.Query
doCreateQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
Object
execute(Object[] parameters)
protected org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor
getJpaParametersParameterAccessor(org.springframework.data.repository.query.Parameters<?,?> parameters, Object[] values)
Get a type and position aware accessor of method parameters.protected Object
getMetadata(Object queryMetadataCache, javax.persistence.Query query)
Get query metadata informationprotected org.springframework.data.jpa.repository.query.ParameterBinder
getParameterBinder(org.springframework.data.jpa.repository.query.JpaParameters parameters, List<?> expressions)
Get the binder component used to apply params supplied in the method call to the JPA query.protected Object
getQueryMetadataCache()
Get the cache of query related metadataprotected void
mergeRsqlCriteriaWithQueryCriteria(javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.Predicate rsqlCriteria)
Replaces thequery
's internalcriteria
with an updated version that is combined with RSQL criteria.javax.persistence.Query
prepareQueryForExecution(javax.persistence.Query query, com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo info, boolean bindFetchCriteria)
Perform final preparation of a JpaQuery
before execution.protected Object
processQuery(Object[] parameters, org.springframework.data.repository.query.ParametersParameterAccessor accessor, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, org.springframework.data.repository.query.ResultProcessor processor, org.springframework.data.jpa.repository.query.JpaQueryCreator creator, javax.persistence.criteria.CriteriaQuery<?> criteriaQuery)
Execute the criteria query through theNarrowExecutor
implementation and return the results.
-
-
-
Field Detail
-
PARAMETER_BINDER
public static final String PARAMETER_BINDER
- See Also:
- Constant Field Values
-
ACCESSOR
public static final String ACCESSOR
- See Also:
- Constant Field Values
-
QUERY_PREPARER
public static final String QUERY_PREPARER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NarrowingPartTreeJpaQuery
public NarrowingPartTreeJpaQuery(org.springframework.data.jpa.repository.query.JpaQueryMethod method, javax.persistence.EntityManager em, org.springframework.data.jpa.provider.PersistenceProvider persistenceProvider, org.springframework.data.jpa.repository.query.EscapeCharacter escape, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, @Nullable RSQLVisitorHolder<?> rsqlVisitorHolder, JpaFiltersCriteriaBuilder catalogFiltersCriteriaBuilder, org.springframework.data.repository.core.RepositoryMetadata repositoryMetadata, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
-
-
Method Detail
-
execute
public Object execute(Object[] parameters)
- Specified by:
execute
in interfaceorg.springframework.data.repository.query.RepositoryQuery
- Overrides:
execute
in classorg.springframework.data.jpa.repository.query.AbstractJpaQuery
-
prepareQueryForExecution
public javax.persistence.Query prepareQueryForExecution(javax.persistence.Query query, com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo info, boolean bindFetchCriteria)
Description copied from interface:QueryPreparer
Perform final preparation of a JpaQuery
before execution.- Specified by:
prepareQueryForExecution
in interfaceQueryPreparer
- Parameters:
query
- The query to prepareinfo
- The information about the query used duringNarrowExecutor
processingbindFetchCriteria
- Whether or not to bind any parameters described inJpaNarrowingHelper.JpaCriterias.getParameterMap()
- Returns:
- the prepared query
-
doCreateQuery
@NonNull protected javax.persistence.Query doCreateQuery(@NonNull org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
- Specified by:
doCreateQuery
in classorg.springframework.data.jpa.repository.query.AbstractJpaQuery
-
doCreateCountQuery
@NonNull protected javax.persistence.Query doCreateCountQuery(@NonNull org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
- Specified by:
doCreateCountQuery
in classorg.springframework.data.jpa.repository.query.AbstractJpaQuery
-
processQuery
protected Object processQuery(Object[] parameters, org.springframework.data.repository.query.ParametersParameterAccessor accessor, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, org.springframework.data.repository.query.ResultProcessor processor, org.springframework.data.jpa.repository.query.JpaQueryCreator creator, javax.persistence.criteria.CriteriaQuery<?> criteriaQuery)
Execute the criteria query through theNarrowExecutor
implementation and return the results.- Parameters:
parameters
- Repository fragment method parametersaccessor
- Type and position aware accessor of method parameterscontext
- ContextInfo from the repository fragment methodprocessor
- Spring processor of query resultscreator
- Source of JPA parameter expressions for the dynamically created criteria querycriteriaQuery
- The dynamically created criteria query (based on the repository fragment method and params)- Returns:
- The query results
-
mergeRsqlCriteriaWithQueryCriteria
protected void mergeRsqlCriteriaWithQueryCriteria(@NonNull javax.persistence.criteria.CriteriaQuery<?> query, @Nullable javax.persistence.criteria.Predicate rsqlCriteria)
Replaces the
query
's internalcriteria
with an updated version that is combined with RSQL criteria. If properties are duplicated between the existing criteria and the new RSQL criteria, they are AND-ed together.If there is no existing criteria on the given
query
, thequery
is updated to contain the givenrsqlCriteria
.- Parameters:
query
- the query whose criteria should be replacedrsqlCriteria
- pre-parsed RSQL criteria which should be merged with the criteria of the query
-
getParameterBinder
protected org.springframework.data.jpa.repository.query.ParameterBinder getParameterBinder(org.springframework.data.jpa.repository.query.JpaParameters parameters, List<?> expressions)
Get the binder component used to apply params supplied in the method call to the JPA query.- Parameters:
parameters
- The method parameters against query parametersexpressions
- The JPA criteria expressions- Returns:
- The binder
-
getMetadata
protected Object getMetadata(Object queryMetadataCache, javax.persistence.Query query)
Get query metadata information- Parameters:
queryMetadataCache
- Cache of metadataquery
- The query from which to derive metadata- Returns:
-
getQueryMetadataCache
protected Object getQueryMetadataCache()
Get the cache of query related metadata- Returns:
- the cache of query related metadata
-
getJpaParametersParameterAccessor
protected org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor getJpaParametersParameterAccessor(org.springframework.data.repository.query.Parameters<?,?> parameters, Object[] values)
Get a type and position aware accessor of method parameters.- Parameters:
parameters
- The method parameters against query parametersvalues
- The actual method parameter values- Returns:
- type and position aware accessor of method parameters
-
bindAndPrepare
protected javax.persistence.Query bindAndPrepare(org.springframework.data.jpa.repository.query.ParameterBinder binder, javax.persistence.Query query, Object metadata, org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
Execute the binding of method params on the query- Parameters:
binder
- The parameter binderquery
- The Jpa querymetadata
- The metadata about the queryaccessor
- The method parameter accessor- Returns:
- The finished version of the query with parameters bound
-
applyEntityGraphConfig
protected javax.persistence.Query applyEntityGraphConfig(javax.persistence.Query query, org.springframework.data.jpa.repository.query.JpaQueryMethod method)
Apply any declared entity graph stipulations on the query.- Parameters:
query
- The jpa querymethod
- The entity graph annotated repository method- Returns:
- The query with information applied
-
applyHints
@NonNull protected javax.persistence.Query applyHints(@NonNull javax.persistence.Query query, org.springframework.data.jpa.repository.query.JpaQueryMethod method)
Apply any declared Jpa hint stipulations on the query.- Overrides:
applyHints
in classorg.springframework.data.jpa.repository.query.AbstractJpaQuery
- Parameters:
query
- The jpa querymethod
- The hint annotated repository method- Returns:
- The query with information applied
-
addSorting
protected <D> void addSorting(javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.CriteriaBuilder cb, Class<D> type)
Apply any declared sort stipulations on the query.- Type Parameters:
D
- The query result entity type- Parameters:
query
- The jpa querycb
- The jpa criteria buildertype
- The query result entity type
-
-