Package 

Class PanacheQueryImpl

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      <NewEntity extends Any> PanacheQuery<NewEntity> project(Class<NewEntity> type) Defines a projection class: the getters, and the public fields, will be used to restrict which fields should be retrieved from the database.
      PanacheQuery<Entity> page(Page page) Sets the current page.
      PanacheQuery<Entity> page(Integer pageIndex, Integer pageSize) Sets the current page.
      Page page() Returns the current page.
      PanacheQuery<Entity> nextPage() Sets the current page to the next page
      PanacheQuery<Entity> previousPage() Sets the current page to the previous page (or the first page if there is no previous page)
      PanacheQuery<Entity> firstPage() Sets the current page to the first page
      PanacheQuery<Entity> lastPage() Sets the current page to the last page.
      Boolean hasNextPage() Returns true if there is another page to read after the current one.
      Boolean hasPreviousPage() Returns true if there is a page to read before the current one.
      Integer pageCount() Returns the total number of pages to be read using the current page size.
      PanacheQuery<Entity> range(Integer startIndex, Integer lastIndex) Switch the query to use a fixed range (start index - last index) instead of a page.
      PanacheQuery<Entity> withLock(LockModeType lockModeType) Define the locking strategy used for this query.
      PanacheQuery<Entity> withHint(String hintName, Object value) Set a query property or hint on the underlying JPA Query.
      PanacheQuery<Entity> filter(String filterName, Parameters parameters) <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
      PanacheQuery<Entity> filter(String filterName, Map<String, Object> parameters) <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
      PanacheQuery<Entity> filter(String filterName) <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
      Long count() Reads and caches the total number of entities this query operates on.
      List<Entity> list() Returns the current page of results as a List.
      Stream<Entity> stream() Returns the current page of results as a Stream.
      Entity firstResult() Returns the first result of the current page index.
      Entity singleResult() Executes this query for the current page and return a single result.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • project

         <NewEntity extends Any> PanacheQuery<NewEntity> project(Class<NewEntity> type)

        Defines a projection class: the getters, and the public fields, will be used to restrict which fields should be retrieved from the database.

      • page

         Page page()

        Returns the current page.

      • hasNextPage

         Boolean hasNextPage()

        Returns true if there is another page to read after the current one. This will cause reading of the entity count.

      • pageCount

         Integer pageCount()

        Returns the total number of pages to be read using the current page size. This will cause reading of the entity count.

      • range

         PanacheQuery<Entity> range(Integer startIndex, Integer lastIndex)

        Switch the query to use a fixed range (start index - last index) instead of a page. As the range is fixed, subsequent pagination of the query is not possible.

        Parameters:
        startIndex - the index of the first element, starting at 0
        lastIndex - the index of the last element
      • withLock

         PanacheQuery<Entity> withLock(LockModeType lockModeType)

        Define the locking strategy used for this query.

        Parameters:
        lockModeType - the locking strategy to be used for this query.
      • withHint

         PanacheQuery<Entity> withHint(String hintName, Object value)

        Set a query property or hint on the underlying JPA Query.

        Parameters:
        hintName - name of the property or hint.
        value - value for the property or hint.
      • filter

         PanacheQuery<Entity> filter(String filterName, Parameters parameters)
        <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
        Parameters:
        filterName - The name of the filter to enable
        parameters - The set of parameters for the filter, if the filter requires parameters
      • filter

         PanacheQuery<Entity> filter(String filterName, Map<String, Object> parameters)
        <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
        Parameters:
        filterName - The name of the filter to enable
        parameters - The set of parameters for the filter, if the filter requires parameters
      • filter

         PanacheQuery<Entity> filter(String filterName)
        <p> Enables a Hibernate filter during fetching of results for this query. Your filter must be declared with [FilterDef] on your entity or package, and enabled with [Filter] on your entity. <p> WARNING: setting filters can only be done on the underlying Hibernate [Session] and so this will modify the session's filters for the duration of obtaining the results (not while building the query). Enabled filters will be removed from the session afterwards, but no effort is made to preserve filters enabled on the session outside of this API.
        Parameters:
        filterName - The name of the filter to enable
      • count

         Long count()

        Reads and caches the total number of entities this query operates on. This causes a database query with <code>SELECT COUNT(*)</code> and a query equivalent to the current query, minus ordering.

      • firstResult

         Entity firstResult()

        Returns the first result of the current page index. This ignores the current page size to fetch a single result.

      • singleResult

         Entity singleResult()

        Executes this query for the current page and return a single result.