Class PreprocessedQuery
java.lang.Object
org.springframework.data.jpa.repository.query.PreprocessedQuery
- All Implemented Interfaces:
DeclaredQuery, QueryProvider
A pre-parsed query implementing
DeclaredQuery providing information about parameter bindings.
Query-preprocessing transforms queries using Spring Data-specific syntax such as query
templating, extended LIKE syntax and usage of value expressions into a syntax that
is valid for JPA queries (JPQL and native).
Preprocessing consists of parsing and rewriting so that no extension elements interfere with downstream parsers.
However, pre-processing is a lossy procedure because the resulting query string only
contains parameter binding markers and so the original query cannot be restored. Any query derivation must align its
parameter bindings to ensure the derived query uses the same binding semantics instead of
plain parameters. See ParameterBinding.isCompatibleWith(ParameterBinding) for further reference.
- Since:
- 4.0
- Author:
- Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn the query string.booleanisNative()Return whether the query is a native query of not.static PreprocessedQueryparse(DeclaredQuery declaredQuery) Parse aqueryinto its parametrized form by identifying anonymous, named, indexed and SpEL parameters.Derive a query (typically a count query) from the given query string.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DeclaredQuery
isJpql
-
Method Details
-
parse
Parse aqueryinto its parametrized form by identifying anonymous, named, indexed and SpEL parameters. Query parsing applies special treatment toINandLIKEparameter bindings.- Parameters:
declaredQuery- the source query to parse.- Returns:
- a parsed
PreprocessedQuery.
-
getQueryString
Description copied from interface:QueryProviderReturn the query string.- Specified by:
getQueryStringin interfaceQueryProvider- Returns:
- the query string.
-
isNative
public boolean isNative()Description copied from interface:DeclaredQueryReturn whether the query is a native query of not.- Specified by:
isNativein interfaceDeclaredQuery- Returns:
- true if native query; false if it is a JPQL query.
-
containsPageableInSpel
public boolean containsPageableInSpel() -
getBindings
-
rewrite
Derive a query (typically a count query) from the given query string. We need to copy expression bindings from the declared to the derived query as JPQL query derivation only sees JPA parameter markers and not the original expressions anymore.- Specified by:
rewritein interfaceDeclaredQuery- Parameters:
newQueryString- the new query string.- Returns:
-
toString
-