Module spring.data.jpa
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) Adds order by clause to the JPQL query.applySorting(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 join aliases of the 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.booleanReturns whether the given JPQL query contains a constructor expression.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
createCountQueryFor
-
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
-
hasConstructorExpression
public boolean hasConstructorExpression()Description copied from interface:QueryEnhancerReturns whether the given JPQL query contains a constructor expression.- Specified by:
hasConstructorExpressionin interfaceQueryEnhancer- Returns:
- whether the given JPQL query contains a constructor expression.
-
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.
-
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
Description copied from interface:QueryEnhancerReturns the join aliases of the query.- Specified by:
getJoinAliasesin interfaceQueryEnhancer- Returns:
- the join aliases of the query.
-
getSelectionAliases
-
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.
-
applySorting
Description copied from interface:QueryEnhancerAdds order by clause to the JPQL query. Uses the first alias to bind the sorting property to.- Specified by:
applySortingin interfaceQueryEnhancer- Parameters:
sort- the sort specification to apply.- Returns:
- the modified query string.
-
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.
-
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.
-