Class DefaultJpaNarrowingHelper
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.jpa.filtering.narrow.DefaultJpaNarrowingHelper
-
- All Implemented Interfaces:
JpaNarrowingHelper
public class DefaultJpaNarrowingHelper extends Object implements JpaNarrowingHelper
- Author:
- Jeff Fischer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
JpaNarrowingHelper.JpaCriterias<D>
-
-
Constructor Summary
Constructors Constructor Description DefaultJpaNarrowingHelper(javax.persistence.EntityManager em, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, JpaFiltersCriteriaBuilder catalogFilterRulesBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo
checkSorting(com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo queryInfo)
<D> Long
count(JpaNarrowingHelper.JpaCriterias<Long> query, Class<D> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed query intended to return a count of matching entity instances.<D,I>
Longcount(JpaNarrowingHelper.JpaCriterias<Long> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed query intended to return a count of matching entity instances.<D> Optional<D>
fetch(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a specific entity instance.<D,I>
Optional<D>fetch(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a specific entity instance.<D> List<D>
fetchAll(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, Integer limit, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a list of entity instances.<D> org.springframework.data.domain.Page<D>
fetchAll(JpaNarrowingHelper.JpaCriterias<?> query, org.springframework.data.domain.Pageable pageable, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a page of entity instances as a subset of a larger result set<D,I>
org.springframework.data.domain.Page<D>fetchAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.domain.Pageable pageable, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a page of entity instances as a subset of a larger result set<D,I>
List<D>fetchAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, Integer limit, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Perform a narrowed fetch intended to return a list of entity instances.<D> Stream<D>
streamAll(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Retrieve query results as a Java 8 stream.<D,I>
Stream<D>streamAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Retrieve query results as a Java 8 stream.
-
-
-
Constructor Detail
-
DefaultJpaNarrowingHelper
public DefaultJpaNarrowingHelper(javax.persistence.EntityManager em, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, JpaFiltersCriteriaBuilder catalogFilterRulesBuilder)
-
-
Method Detail
-
fetch
public <D,I> Optional<D> fetch(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a specific entity instance.- Specified by:
fetch
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entityI
- The type of the entity's primary key- Parameters:
query
- The single result queryinfo
- Metadata about the entity being retrievedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- A container for the returned entity, which in fact, may contain nothing if there was nothing found
-
fetchAll
public <D,I> List<D> fetchAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, Integer limit, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a list of entity instances.- Specified by:
fetchAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entityI
- The type of the entity's primary key- Parameters:
query
- The list result queryinfo
- Metadata about the entity being retrievedlimit
- (Optional) The maximum number of results to fetchcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The narrowed results of the query, which may be an empty list if no results were found
-
fetchAll
public <D,I> org.springframework.data.domain.Page<D> fetchAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.domain.Pageable pageable, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a page of entity instances as a subset of a larger result set- Specified by:
fetchAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entityI
- The type of the entity's primary key- Parameters:
query
- The page result querypageable
- The information regarding the page of data to retrieveinfo
- Metadata about the entity being retrievedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The narrowed page of results for the query
-
fetch
public <D> Optional<D> fetch(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a specific entity instance.- Specified by:
fetch
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entity- Parameters:
query
- The single result querytype
- The type being retrievedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- A container for the returned entity, which in fact, may contain nothing if there was nothing found
-
fetchAll
public <D> List<D> fetchAll(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, Integer limit, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a list of entity instances.- Specified by:
fetchAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entity- Parameters:
query
- The list result querytype
- The type being retrievedlimit
- (Optional) The maximum number of results to fetchcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The narrowed results of the query, which may be an empty list if no results were found
-
fetchAll
public <D> org.springframework.data.domain.Page<D> fetchAll(JpaNarrowingHelper.JpaCriterias<?> query, org.springframework.data.domain.Pageable pageable, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed fetch intended to return a page of entity instances as a subset of a larger result set- Specified by:
fetchAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The type of the entity- Parameters:
query
- The page result querypageable
- The information regarding the page of data to retrievetype
- The type being retrievedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The narrowed page of results for the query
-
streamAll
public <D,I> Stream<D> streamAll(JpaNarrowingHelper.JpaCriterias<D> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Retrieve query results as a Java 8 stream. Note, for this to work as a true, cursor-driven stream, there are often additional configuration requirements, depending on the database provider. Also, a transaction must surround the processing of the stream in order to maintain the cursor, which may be undesirable. Also note that some jdbc providers will simply take a list of results and return that as a stream, which is no additional benefit over retrieving the results as a list. Please refer to the documentation for your database driver for more specifics on how to handle streaming results with Jpa.- Specified by:
streamAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The result typeI
- The type of the entity primary key- Parameters:
query
- The query to streaminfo
- Type information about the result entitycontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The results of the query as a stream (possibly cursor driven)
-
streamAll
public <D> Stream<D> streamAll(JpaNarrowingHelper.JpaCriterias<?> query, Class<?> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Retrieve query results as a Java 8 stream. Note, for this to work as a true, cursor-driven stream, there are often additional configuration requirements, depending on the database provider. Also, a transaction must surround the processing of the stream in order to maintain the cursor, which may be undesirable. Also note that some jdbc providers will simply take a list of results and return that as a stream, which is no additional benefit over retrieving the results as a list. Please refer to the documentation for your database driver for more specifics on how to handle streaming results with Jpa.- Specified by:
streamAll
in interfaceJpaNarrowingHelper
- Type Parameters:
D
- The result type- Parameters:
query
- The query to streamtype
- The result typecontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The results of the query as a stream (possibly cursor driven)
-
count
public <D> Long count(JpaNarrowingHelper.JpaCriterias<Long> query, Class<D> type, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed query intended to return a count of matching entity instances.- Specified by:
count
in interfaceJpaNarrowingHelper
- Parameters:
query
- The long result querytype
- The type being countedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The count of matching entity instances
-
count
public <D,I> Long count(JpaNarrowingHelper.JpaCriterias<Long> query, org.springframework.data.jpa.repository.support.JpaEntityInformation<D,I> info, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:JpaNarrowingHelper
Perform a narrowed query intended to return a count of matching entity instances.- Specified by:
count
in interfaceJpaNarrowingHelper
- Parameters:
query
- The long result queryinfo
- Metadata about the entity being retrievedcontext
- Context information used for narrowing (e.g. sandbox or multitenant information)- Returns:
- The count of matching entity instances
-
checkSorting
protected com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo checkSorting(com.broadleafcommerce.data.tracking.core.filtering.NarrowExecutor.QueryInfo queryInfo)
-
-