Interface JpaNarrowingHelper

  • All Known Implementing Classes:
    DefaultJpaNarrowingHelper

    public interface JpaNarrowingHelper
    Helper for dealing with explicitly constructed JpaNarrowingHelper.JpaCriterias instances in order to make sure the results of those queries are filtered using a NarrowExecutor.
    Author:
    Jeff Fischer
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  JpaNarrowingHelper.JpaCriterias<D>
      Represents a query or queries to utilize for a fetch through the target NarrowExecutor.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <D> Long count​(JpaNarrowingHelper.JpaCriterias<Long> jpaCriterias, 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> jpaCriterias, 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<?> jpaCriterias, 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> jpaCriterias, 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<?> jpaCriterias, 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<?> jpaCriterias, 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> jpaCriterias, 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> jpaCriterias, 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<?> jpaCriterias, 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> jpaCriterias, 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.
    • Method Detail

      • fetch

        <D,​I> Optional<D> fetch​(JpaNarrowingHelper.JpaCriterias<D> jpaCriterias,
                                      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.
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        jpaCriterias - 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

        <D,​I> List<D> fetchAll​(JpaNarrowingHelper.JpaCriterias<D> jpaCriterias,
                                     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.
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        jpaCriterias - The list result query
        info - Metadata about the entity being retrieved
        context - Context information used for narrowing (e.g. sandbox or multitenant information)
        limit - (Optional) The maximum number of results to fetch
        Returns:
        The narrowed results of the query, which may be an empty list if no results were found
      • fetchAll

        <D,​I> org.springframework.data.domain.Page<D> fetchAll​(JpaNarrowingHelper.JpaCriterias<D> jpaCriterias,
                                                                     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
        Type Parameters:
        D - The type of the entity
        I - The type of the entity's primary key
        Parameters:
        jpaCriterias - 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
      • streamAll

        <D,​I> Stream<D> streamAll​(JpaNarrowingHelper.JpaCriterias<D> jpaCriterias,
                                        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. 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.
        Type Parameters:
        D - The result type
        I - The type of the entity primary key
        Parameters:
        jpaCriterias - 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)
      • fetch

        <D> Optional<D> fetch​(JpaNarrowingHelper.JpaCriterias<?> jpaCriterias,
                              Class<?> type,
                              com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Perform a narrowed fetch intended to return a specific entity instance.
        Type Parameters:
        D - The type of the entity
        Parameters:
        jpaCriterias - 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

        <D> List<D> fetchAll​(JpaNarrowingHelper.JpaCriterias<?> jpaCriterias,
                             Class<?> type,
                             Integer limit,
                             com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Perform a narrowed fetch intended to return a list of entity instances.
        Type Parameters:
        D - The type of the entity
        Parameters:
        jpaCriterias - 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

        <D> org.springframework.data.domain.Page<D> fetchAll​(JpaNarrowingHelper.JpaCriterias<?> jpaCriterias,
                                                             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
        Type Parameters:
        D - The type of the entity
        Parameters:
        jpaCriterias - 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

        <D> Stream<D> streamAll​(JpaNarrowingHelper.JpaCriterias<?> jpaCriterias,
                                Class<?> type,
                                com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        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.
        Type Parameters:
        D - The result type
        Parameters:
        jpaCriterias - 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

        <D> Long count​(JpaNarrowingHelper.JpaCriterias<Long> jpaCriterias,
                       Class<D> type,
                       com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Perform a narrowed query intended to return a count of matching entity instances.
        Parameters:
        jpaCriterias - 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

        <D,​I> Long count​(JpaNarrowingHelper.JpaCriterias<Long> jpaCriterias,
                               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.
        Parameters:
        jpaCriterias - 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