Class DefaultJpaNarrowingHelper

    • 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>
      Long
      count​(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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        query - The single result query
        info - Metadata about the entity being retrieved
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        query - The list result query
        info - Metadata about the entity being retrieved
        limit - (Optional) The maximum number of results to fetch
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        query - The page result query
        pageable - The information regarding the page of data to retrieve
        info - Metadata about the entity being retrieved
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        Parameters:
        query - The single result query
        type - The type being retrieved
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        Parameters:
        query - The list result query
        type - The type being retrieved
        limit - (Optional) The maximum number of results to fetch
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The type of the entity
        Parameters:
        query - The page result query
        pageable - The information regarding the page of data to retrieve
        type - The type being retrieved
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The result type
        I - The type of the entity primary key
        Parameters:
        query - The query to stream
        info - Type information about the result entity
        context - 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 interface JpaNarrowingHelper
        Type Parameters:
        D - The result type
        Parameters:
        query - The query to stream
        type - The result type
        context - 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 interface JpaNarrowingHelper
        Parameters:
        query - The long result query
        type - The type being counted
        context - 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 interface JpaNarrowingHelper
        Parameters:
        query - The long result query
        info - Metadata about the entity being retrieved
        context - 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)