Class DefaultQueryEnhancer
java.lang.Object
org.springframework.data.jpa.repository.query.DefaultQueryEnhancer
- All Implemented Interfaces:
QueryEnhancer
The implementation of the Regex-based
QueryEnhancer
using QueryUtils
.- Since:
- 2.7.0
- Author:
- Diego Krupitza
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.query.QueryEnhancer
QueryEnhancer.QueryRewriteInformation
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultQueryEnhancer
(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 betweenselect
andfrom
.org.springframework.data.jpa.repository.query.DeclaredQuery
getQuery()
Gets the query we want to use for enhancements.boolean
Returns whether the given JPQL query contains a constructor expression.rewrite
(QueryEnhancer.QueryRewriteInformation rewriteInformation) Rewrite the query to include sorting and applyReturnedType
customizations.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.jpa.repository.query.QueryEnhancer
createCountQueryFor
-
Constructor Details
-
DefaultQueryEnhancer
public DefaultQueryEnhancer(org.springframework.data.jpa.repository.query.DeclaredQuery query)
-
-
Method Details
-
applySorting
Description copied from interface:QueryEnhancer
Adds order by clause to the JPQL query. Uses the first alias to bind the sorting property to.- Specified by:
applySorting
in interfaceQueryEnhancer
- Parameters:
sort
- the sort specification to apply.- Returns:
- the modified query string.
-
applySorting
Description copied from interface:QueryEnhancer
Adds order by clause to the JPQL query.- Specified by:
applySorting
in 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.
-
rewrite
Description copied from interface:QueryEnhancer
Rewrite the query to include sorting and applyReturnedType
customizations.- Specified by:
rewrite
in interfaceQueryEnhancer
- Parameters:
rewriteInformation
- the rewrite information to apply.- Returns:
- the modified query string.
-
createCountQueryFor
Description copied from interface:QueryEnhancer
Creates a count projected query from the given original query using the providedcountProjection
.- Specified by:
createCountQueryFor
in interfaceQueryEnhancer
- Parameters:
countProjection
- may be null.- Returns:
- a query String to be used a count query for pagination. Guaranteed to be not null.
-
hasConstructorExpression
public boolean hasConstructorExpression()Description copied from interface:QueryEnhancer
Returns whether the given JPQL query contains a constructor expression.- Specified by:
hasConstructorExpression
in interfaceQueryEnhancer
- Returns:
- whether the given JPQL query contains a constructor expression.
-
detectAlias
Description copied from interface:QueryEnhancer
Resolves the alias for the entity to be retrieved from the given JPA query.- Specified by:
detectAlias
in interfaceQueryEnhancer
- Returns:
- Might return null.
-
getProjection
Description copied from interface:QueryEnhancer
Returns the projection part of the query, i.e. everything betweenselect
andfrom
.- Specified by:
getProjection
in interfaceQueryEnhancer
- Returns:
- the projection part of the query.
-
getJoinAliases
Description copied from interface:QueryEnhancer
Returns the join aliases of the query.- Specified by:
getJoinAliases
in interfaceQueryEnhancer
- Returns:
- the join aliases of the query.
-
getQuery
public org.springframework.data.jpa.repository.query.DeclaredQuery getQuery()Description copied from interface:QueryEnhancer
Gets the query we want to use for enhancements.- Specified by:
getQuery
in interfaceQueryEnhancer
- Returns:
- non-null
DeclaredQuery
that wraps the query.
-