Interface DeclaredQuery

All Superinterfaces:
QueryProvider
All Known Implementing Classes:
PreprocessedQuery

public interface DeclaredQuery extends QueryProvider
Interface defining the contract to represent a declared query.

Declared queries consist of a query string and a flag whether the query is a native (SQL) one or a JPQL query. Queries can be rewritten to contain a different query string (i.e. count query derivation, sorting, projection updates) while retaining their native flag.

Since:
2.0.3
Author:
Jens Schauder, Diego Krupitza, Mark Paluch
  • Method Details

    • jpqlQuery

      static DeclaredQuery jpqlQuery(String jpql)
      Creates a DeclaredQuery for a JPQL query.
      Parameters:
      jpql - the JPQL query string.
      Returns:
      new instance of DeclaredQuery.
    • nativeQuery

      static DeclaredQuery nativeQuery(String sql)
      Creates a DeclaredQuery for a native query.
      Parameters:
      sql - the native query string.
      Returns:
      new instance of DeclaredQuery.
    • isNative

      boolean isNative()
      Return whether the query is a native query of not.
      Returns:
      true if native query; false if it is a JPQL query.
    • isJpql

      default boolean isJpql()
      Return whether the query is a JPQL query of not.
      Returns:
      true if JPQL query; false if it is a native query.
      Since:
      4.0
    • rewrite

      default DeclaredQuery rewrite(String newQueryString)
      Rewrite a query string using a new query string retaining its source and native flag.
      Parameters:
      newQueryString - the new query string.
      Returns:
      the rewritten DeclaredQuery.
      Since:
      4.0