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 Type
    Method
    Description
    Adds order by clause to the JPQL query.
    applySorting(Sort sort, String alias)
    Deprecated.
    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 provided countProjection.
    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 between select and from.
    org.springframework.data.jpa.repository.query.DeclaredQuery
    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.
  • 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

      @Nullable String 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 between select and from.
      Returns:
      the projection part of the query.
    • getJoinAliases

      @Deprecated(forRemoval=true) Set<String> 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(forRemoval=true) org.springframework.data.jpa.repository.query.DeclaredQuery 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

      String applySorting(Sort sort)
      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 String applySorting(Sort sort, @Nullable String alias)
      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

      default String createCountQueryFor()
      Creates a count projected query from the given original query.
      Returns:
      Guaranteed to be not null.
    • createCountQueryFor

      String createCountQueryFor(@Nullable String countProjection)
      Creates a count projected query from the given original query using the provided countProjection.
      Parameters:
      countProjection - may be null.
      Returns:
      a query String to be used a count query for pagination. Guaranteed to be not null.