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, Diego Pedregal, Soomin Kim
-
Nested Class Summary
Nested classes/interfaces inherited from interface QueryEnhancer
QueryEnhancer.QueryRewriteInformation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCountQueryFor(@Nullable String countProjection) Creates a count projected query from the given original query using the providedcountProjection.@Nullable StringResolves the primary alias for the entity to be retrieved from the given JPA query.Returns the projection part of the query, i.e. everything betweenselectandfrom.getQuery()Gets the query we want to use for enhancements.booleanReturns whether the given JPQL query contains a constructor expression.booleanrewrite(QueryEnhancer.QueryRewriteInformation rewriteInformation) Rewrite the query to include sorting and applyReturnedTypecustomizations.
-
Constructor Details
-
JSqlParserQueryEnhancer
- Parameters:
query- the query we want to enhance. Must not be null.
-
-
Method Details
-
isSelectQuery
public boolean isSelectQuery()- Specified by:
isSelectQueryin interfaceQueryEnhancer- Returns:
- whether the underlying query is a SELECT query.
-
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 primary alias for the entity to be retrieved from the given JPA query.- Specified by:
detectAliasin interfaceQueryEnhancer- Returns:
- can 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.
-
getSelectionAliases
-
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.
-
rewrite
Description copied from interface:QueryEnhancerRewrite the query to include sorting and applyReturnedTypecustomizations.- Specified by:
rewritein interfaceQueryEnhancer- Parameters:
rewriteInformation- the rewrite information to apply.- 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.
-