Interface QueryEnhancer

All Known Implementing Classes:
JSqlParserQueryEnhancer

public interface QueryEnhancer
This interface describes the API for enhancing a given Query.
Since:
2.7
Author:
Diego Krupitza, Greg Turnquist, Mark Paluch
  • Method Details

    • create

      static QueryEnhancer create(DeclaredQuery query)
      Creates a new QueryEnhancer for a DeclaredQuery. Convenience method for QueryEnhancerFactory.create(QueryProvider).
      Parameters:
      query - the query to be enhanced.
      Returns:
      the new QueryEnhancer.
      Since:
      4.0
    • 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 primary alias for the entity to be retrieved from the given JPA query.
      Returns:
      can 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.
    • getQuery

      QueryProvider getQuery()
      Gets the query we want to use for enhancements.
      Returns:
      non-null DeclaredQuery that wraps the query.
    • rewrite

      String rewrite(QueryEnhancer.QueryRewriteInformation rewriteInformation)
      Rewrite the query to include sorting and apply ReturnedType customizations.
      Parameters:
      rewriteInformation - the rewrite information to apply.
      Returns:
      the modified query string.
      Since:
      4.0
    • 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.