Interface QueryEnhancer
- All Known Implementing Classes:
DefaultQueryEnhancer
,JSqlParserQueryEnhancer
public interface QueryEnhancer
This interface describes the API for enhancing a given Query.
- Since:
- 2.7.0
- Author:
- Diego Krupitza, Greg Turnquist
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Interface to describe the information needed to rewrite a query. -
Method Summary
Modifier and TypeMethodDescriptionapplySorting
(Sort sort) Adds order by clause to the JPQL query.applySorting
(Sort sort, String alias) Deprecated, for removal: This API element is subject to removal in a future version.default String
Creates a count projected query from the given original 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.Deprecated, for removal: This API element is subject to removal in a future version.Returns the projection part of the query, i.e. everything betweenselect
andfrom
.org.springframework.data.jpa.repository.query.DeclaredQuery
getQuery()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
Returns whether the given JPQL query contains a constructor expression.rewrite
(QueryEnhancer.QueryRewriteInformation rewriteInformation) Rewrite the query to include sorting and applyReturnedType
customizations.
-
Method Details
-
hasConstructorExpression
boolean hasConstructorExpression()Returns whether the given JPQL query contains a constructor expression.- Returns:
- whether the given JPQL query contains a constructor expression.
-
detectAlias
Resolves the alias for the entity to be retrieved from the given JPA query.- Returns:
- Might return null.
-
getProjection
String getProjection()Returns the projection part of the query, i.e. everything betweenselect
andfrom
.- Returns:
- the projection part of the query.
-
getJoinAliases
Deprecated, for removal: This API element is subject to removal in a future version.Returns the join aliases of the query.- Returns:
- the join aliases of the query.
-
getQuery
Deprecated, for removal: This API element is subject to removal in a future version.Gets the query we want to use for enhancements.- Returns:
- non-null
DeclaredQuery
that wraps the query.
-
applySorting
Adds order by clause to the JPQL query. Uses the first alias to bind the sorting property to.- Parameters:
sort
- the sort specification to apply.- Returns:
- the modified query string.
-
applySorting
Deprecated, for removal: This API element is subject to removal in a future version.since 3.5, userewrite(QueryRewriteInformation)
instead.Adds order by clause to the JPQL query.- 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.
-
rewrite
Rewrite the query to include sorting and applyReturnedType
customizations.- Parameters:
rewriteInformation
- the rewrite information to apply.- Returns:
- the modified query string.
- Since:
- 3.5
-
createCountQueryFor
Creates a count projected query from the given original query.- Returns:
- Guaranteed to be not null.
-
createCountQueryFor
Creates a count projected query from the given original query using the providedcountProjection
.- Parameters:
countProjection
- may be null.- Returns:
- a query String to be used a count query for pagination. Guaranteed to be not null.
-
rewrite(QueryRewriteInformation)
instead.