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
-
Constructor Summary
ConstructorsConstructorDescriptionJSqlParserQueryEnhancer(org.springframework.data.jpa.repository.query.DeclaredQuery query) -
Method Summary
Modifier and TypeMethodDescriptionapplySorting(org.springframework.data.domain.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 betweenselectandfrom.org.springframework.data.jpa.repository.query.DeclaredQuerygetQuery()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, waitMethods 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:QueryEnhancerAdds order by clause to the JPQL query.- Specified by:
applySortingin 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:QueryEnhancerResolves the alias for the entity to be retrieved from the given JPA query.- Specified by:
detectAliasin interfaceQueryEnhancer- Returns:
- Might return null.
-
createCountQueryFor
Description copied from interface:QueryEnhancerCreates a count projected query from the given original query using the providedcountProjection.- Specified by:
createCountQueryForin 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:QueryEnhancerReturns the projection part of the query, i.e. everything betweenselectandfrom.- Specified by:
getProjectionin interfaceQueryEnhancer- Returns:
- the projection part of the query.
-
getJoinAliases
- Specified by:
getJoinAliasesin interfaceQueryEnhancer
-
getQuery
public org.springframework.data.jpa.repository.query.DeclaredQuery getQuery()Description copied from interface:QueryEnhancerGets the query we want to use for enhancements.- Specified by:
getQueryin interfaceQueryEnhancer- Returns:
- non-null
DeclaredQuerythat wraps the query
-