Class DefaultQueryEnhancer

java.lang.Object
org.springframework.data.jpa.repository.query.DefaultQueryEnhancer
All Implemented Interfaces:
QueryEnhancer

public class DefaultQueryEnhancer extends Object implements QueryEnhancer
The implementation of QueryEnhancer using QueryUtils.
Since:
2.7.0
Author:
Diego Krupitza
  • Constructor Details

    • DefaultQueryEnhancer

      public DefaultQueryEnhancer(org.springframework.data.jpa.repository.query.DeclaredQuery query)
  • Method Details

    • applySorting

      public String applySorting(org.springframework.data.domain.Sort sort, @Nullable String alias)
      Description copied from interface: QueryEnhancer
      Adds order by clause to the JPQL query.
      Specified by:
      applySorting in interface QueryEnhancer
      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.
    • detectAlias

      public String detectAlias()
      Description copied from interface: QueryEnhancer
      Resolves the alias for the entity to be retrieved from the given JPA query.
      Specified by:
      detectAlias in interface QueryEnhancer
      Returns:
      Might return null.
    • createCountQueryFor

      public String createCountQueryFor(@Nullable String countProjection)
      Description copied from interface: QueryEnhancer
      Creates a count projected query from the given original query using the provided countProjection.
      Specified by:
      createCountQueryFor in interface QueryEnhancer
      Parameters:
      countProjection - may be null.
      Returns:
      a query String to be used a count query for pagination. Guaranteed to be not null.
    • getProjection

      public String getProjection()
      Description copied from interface: QueryEnhancer
      Returns the projection part of the query, i.e. everything between select and from.
      Specified by:
      getProjection in interface QueryEnhancer
      Returns:
      the projection part of the query.
    • getJoinAliases

      public Set<String> getJoinAliases()
      Specified by:
      getJoinAliases in interface QueryEnhancer
    • 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 interface QueryEnhancer
      Returns:
      non-null DeclaredQuery that wraps the query