Class JSqlParserQueryEnhancer
java.lang.Object
org.springframework.data.jpa.repository.query.JSqlParserQueryEnhancer
- All Implemented Interfaces:
QueryEnhancer
The implementation of
QueryEnhancer
using JSqlParser.- Since:
- 2.7.0
- Author:
- Diego Krupitza, Greg Turnquist, Geoffrey Deremetz, Yanming Zhou, Christoph Strobl
-
Constructor Summary
ConstructorsConstructorDescriptionJSqlParserQueryEnhancer
(org.springframework.data.jpa.repository.query.DeclaredQuery query) -
Method Summary
Modifier and TypeMethodDescriptionapplySorting
(Sort sort, String alias) Adds order by clause to the JPQL query.createCountQueryFor
(String countProjection) Creates a count projected query from the given original query using the providedcountProjection
.Resolves the alias for the entity to be retrieved from the given JPA query.Returns the projection part of the query, i.e. everything betweenselect
andfrom
.org.springframework.data.jpa.repository.query.DeclaredQuery
getQuery()
Gets the query we want to use for enhancements.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.jpa.repository.query.QueryEnhancer
applySorting, createCountQueryFor, hasConstructorExpression
-
Constructor Details
-
JSqlParserQueryEnhancer
public JSqlParserQueryEnhancer(org.springframework.data.jpa.repository.query.DeclaredQuery query) - Parameters:
query
- the query we want to enhance. Must not be null.
-
-
Method Details
-
applySorting
Description copied from interface:QueryEnhancer
Adds order by clause to the JPQL query.- Specified by:
applySorting
in interfaceQueryEnhancer
- Parameters:
sort
- the sort specification to apply.alias
- the alias to be used in the order by clause. May be null or empty.- Returns:
- the modified query string.
-
detectAlias
Description copied from interface:QueryEnhancer
Resolves the alias for the entity to be retrieved from the given JPA query.- Specified by:
detectAlias
in interfaceQueryEnhancer
- Returns:
- Might return null.
-
createCountQueryFor
Description copied from interface:QueryEnhancer
Creates a count projected query from the given original query using the providedcountProjection
.- Specified by:
createCountQueryFor
in interfaceQueryEnhancer
- Parameters:
countProjection
- may be null.- Returns:
- a query String to be used a count query for pagination. Guaranteed to be not null.
-
getProjection
Description copied from interface:QueryEnhancer
Returns the projection part of the query, i.e. everything betweenselect
andfrom
.- Specified by:
getProjection
in interfaceQueryEnhancer
- Returns:
- the projection part of the query.
-
getJoinAliases
- Specified by:
getJoinAliases
in interfaceQueryEnhancer
-
getQuery
public org.springframework.data.jpa.repository.query.DeclaredQuery getQuery()Description copied from interface:QueryEnhancer
Gets the query we want to use for enhancements.- Specified by:
getQuery
in interfaceQueryEnhancer
- Returns:
- non-null
DeclaredQuery
that wraps the query
-