Module spring.data.jpa
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
-
Method Summary
Modifier and TypeMethodDescriptionapplySorting(Sort sort) Adds order by clause to the JPQL query.applySorting(Sort sort, String alias) Deprecated.default StringCreates 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 betweenselectandfrom.org.springframework.data.jpa.repository.query.DeclaredQuerygetQuery()Deprecated, for removal: This API element is subject to removal in a future version.booleanReturns whether the given JPQL query contains a constructor expression.
-
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 betweenselectandfrom.- 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
DeclaredQuerythat 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.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.
-
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.
-