Class JSqlParserQueryEnhancer

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

public class JSqlParserQueryEnhancer extends Object implements QueryEnhancer
The implementation of QueryEnhancer using JSqlParser.
Since:
2.7.0
Author:
Diego Krupitza, Greg Turnquist, Geoffrey Deremetz, Yanming Zhou, Christoph Strobl, Diego Pedregal, Soomin Kim
  • Constructor Details

    • JSqlParserQueryEnhancer

      public JSqlParserQueryEnhancer(QueryProvider query)
      Parameters:
      query - the query we want to enhance. Must not be null.
  • Method Details

    • isSelectQuery

      public boolean isSelectQuery()
      Specified by:
      isSelectQuery in interface QueryEnhancer
      Returns:
      whether the underlying query is a SELECT query.
    • hasConstructorExpression

      public boolean hasConstructorExpression()
      Description copied from interface: QueryEnhancer
      Returns whether the given JPQL query contains a constructor expression.
      Specified by:
      hasConstructorExpression in interface QueryEnhancer
      Returns:
      whether the given JPQL query contains a constructor expression.
    • detectAlias

      public @Nullable String detectAlias()
      Description copied from interface: QueryEnhancer
      Resolves the primary alias for the entity to be retrieved from the given JPA query.
      Specified by:
      detectAlias in interface QueryEnhancer
      Returns:
      can return 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.
    • getSelectionAliases

      public Set<String> getSelectionAliases()
    • getQuery

      public QueryProvider 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.
    • rewrite

      public String rewrite(QueryEnhancer.QueryRewriteInformation rewriteInformation)
      Description copied from interface: QueryEnhancer
      Rewrite the query to include sorting and apply ReturnedType customizations.
      Specified by:
      rewrite in interface QueryEnhancer
      Parameters:
      rewriteInformation - the rewrite information to apply.
      Returns:
      the modified query string.
    • 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.