Interface ExtendedQuerySupport


public interface ExtendedQuerySupport
Interface implemented by the criteria provider. It is invoked to do some extended functionality like retrieving sql and executing statements with custom sql.
Since:
1.1.0
Author:
Christian Beikov
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Provides SQL information about a FROM element.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    applyFirstResultMaxResults(javax.persistence.Query query, int firstResult, int maxResults)
    Applies the first and max results to the query.
    executeReturning(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query baseQuery, javax.persistence.Query exampleQuery, String sqlOverride, boolean queryPlanCacheEnabled)
    Executes and returns the returning result of the Query by replacing the SQL with the given overriding SQL query.
    int
    executeUpdate(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query baseQuery, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
    Executes and returns the update count of the Query by replacing the SQL with the given overriding SQL query.
    getCascadingDeleteSql(javax.persistence.EntityManager em, javax.persistence.Query query)
    Returns the cascading SQL delete queries for the given query object.
    getResultList(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
    Returns the result list of the Query by replacing the SQL with the given overriding SQL query.
    getResultStream(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
    Returns the result stream of the Query by replacing the SQL with the given overriding SQL query.
    getSingleResult(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
    Returns the single result of the Query by replacing the SQL with the given overriding SQL query.
    getSql(javax.persistence.EntityManager em, javax.persistence.Query query)
    Returns the SQL query for the given query object.
    getSqlAlias(javax.persistence.EntityManager em, javax.persistence.Query query, String alias, int queryPartNumber)
    Returns the SQL table alias of the JPQL from node alias in the given query.
    boolean
    Returns whether the return of getSql(EntityManager, Query) will also contain the limit/offset in the SQL.
    getSqlFromInfo(javax.persistence.EntityManager em, javax.persistence.Query query, String alias, int queryPartNumber)
    Returns the SQL table alias of the JPQL from node alias in the given query.
    int
    getSqlSelectAliasPosition(javax.persistence.EntityManager em, javax.persistence.Query query, String alias)
    Returns the corresponding position of the given JPQL select alias in the SQL query's select clause of the given query object.
    int
    getSqlSelectAttributePosition(javax.persistence.EntityManager em, javax.persistence.Query query, String attribute)
    Returns the corresponding position of the given JPQL attribute expression in the SQL query's select clause of the given query object.
    boolean
    Returns whether the JPA provider needs an example query for advanced sql DML queries.
    boolean
    Returns whether the JPA provider supports advanced sql queries that need every method of this interface to work properly.
  • Method Details

    • supportsAdvancedSql

      boolean supportsAdvancedSql()
      Returns whether the JPA provider supports advanced sql queries that need every method of this interface to work properly.
      Returns:
      Whether advanced sql queries are supported
    • needsExampleQueryForAdvancedDml

      boolean needsExampleQueryForAdvancedDml()
      Returns whether the JPA provider needs an example query for advanced sql DML queries.
      Returns:
      Whether advanced sql DML queries need an example query
      Since:
      1.5.0
    • applyFirstResultMaxResults

      boolean applyFirstResultMaxResults(javax.persistence.Query query, int firstResult, int maxResults)
      Applies the first and max results to the query.
      Parameters:
      query - The query to apply the first and max results
      firstResult - The first result to apply
      maxResults - The max results to apply
      Returns:
      Whether firstResult or maxResult was set or unset whereas before it wasn't
      Since:
      1.6.7
    • getSql

      String getSql(javax.persistence.EntityManager em, javax.persistence.Query query)
      Returns the SQL query for the given query object.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      Returns:
      The SQL query
    • getSqlContainsLimit

      boolean getSqlContainsLimit()
      Returns whether the return of getSql(EntityManager, Query) will also contain the limit/offset in the SQL.
      Returns:
      Whether getSql(EntityManager, Query) contains the limit/offset
      Since:
      1.6.7
    • getCascadingDeleteSql

      List<String> getCascadingDeleteSql(javax.persistence.EntityManager em, javax.persistence.Query query)
      Returns the cascading SQL delete queries for the given query object.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      Returns:
      The cascading SQL delete queries
    • getSqlAlias

      String getSqlAlias(javax.persistence.EntityManager em, javax.persistence.Query query, String alias, int queryPartNumber)
      Returns the SQL table alias of the JPQL from node alias in the given query.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      alias - The from node alias
      queryPartNumber - The 0-based query part number
      Returns:
      The SQL table alias
    • getSqlFromInfo

      ExtendedQuerySupport.SqlFromInfo getSqlFromInfo(javax.persistence.EntityManager em, javax.persistence.Query query, String alias, int queryPartNumber)
      Returns the SQL table alias of the JPQL from node alias in the given query.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      alias - The from node alias
      queryPartNumber - The 0-based query part number
      Returns:
      The SQL table alias position in the SQL string
      Since:
      1.6.7
    • getSqlSelectAliasPosition

      int getSqlSelectAliasPosition(javax.persistence.EntityManager em, javax.persistence.Query query, String alias)
      Returns the corresponding position of the given JPQL select alias in the SQL query's select clause of the given query object.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      alias - The JPQL select alias
      Returns:
      The position of the corresponding SQL select clause item
    • getSqlSelectAttributePosition

      int getSqlSelectAttributePosition(javax.persistence.EntityManager em, javax.persistence.Query query, String attribute)
      Returns the corresponding position of the given JPQL attribute expression in the SQL query's select clause of the given query object.
      Parameters:
      em - The entity manager the query is associated to
      query - The JPA query
      attribute - The JPQL attribute expression
      Returns:
      The position of the corresponding SQL select clause item
    • getResultList

      List getResultList(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
      Returns the result list of the Query by replacing the SQL with the given overriding SQL query.
      Parameters:
      serviceProvider - The service provider to access EntityManager and others
      participatingQueries - The list of participating queries from which to combine parameters
      query - The main query to execute
      sqlOverride - The actual SQL query to execute instead of the query's original SQL
      queryPlanCacheEnabled - Designates whether query plans can be cached and reused
      Returns:
      The result of the query
    • getResultStream

      Object getResultStream(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
      Returns the result stream of the Query by replacing the SQL with the given overriding SQL query.
      Parameters:
      serviceProvider - The service provider to access EntityManager and others
      participatingQueries - The list of participating queries from which to combine parameters
      query - The main query to execute
      sqlOverride - The actual SQL query to execute instead of the query's original SQL
      queryPlanCacheEnabled - Designates whether query plans can be cached and reused
      Returns:
      The result of the query
      Since:
      1.6.2
    • getSingleResult

      Object getSingleResult(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
      Returns the single result of the Query by replacing the SQL with the given overriding SQL query.
      Parameters:
      serviceProvider - The service provider to access EntityManager and others
      participatingQueries - The list of participating queries from which to combine parameters
      query - The main query to execute
      sqlOverride - The actual SQL query to execute instead of the query's original SQL
      queryPlanCacheEnabled - Designates whether query plans can be cached and reused
      Returns:
      The result of the query
    • executeUpdate

      int executeUpdate(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query baseQuery, javax.persistence.Query query, String sqlOverride, boolean queryPlanCacheEnabled)
      Executes and returns the update count of the Query by replacing the SQL with the given overriding SQL query.
      Parameters:
      serviceProvider - The service provider to access EntityManager and others
      participatingQueries - The list of participating queries from which to combine parameters
      baseQuery - The base query which represents the original modification query
      query - The main query to execute
      sqlOverride - The actual SQL query to execute instead of the query's original SQL
      queryPlanCacheEnabled - Designates whether query plans can be cached and reused
      Returns:
      The update count of the query
    • executeReturning

      ReturningResult<Object[]> executeReturning(ServiceProvider serviceProvider, List<javax.persistence.Query> participatingQueries, javax.persistence.Query baseQuery, javax.persistence.Query exampleQuery, String sqlOverride, boolean queryPlanCacheEnabled)
      Executes and returns the returning result of the Query by replacing the SQL with the given overriding SQL query.
      Parameters:
      serviceProvider - The service provider to access EntityManager and others
      participatingQueries - The list of participating queries from which to combine parameters
      baseQuery - The base query which represents the original modification query
      exampleQuery - The example query providing the result type structure
      sqlOverride - The actual SQL query to execute instead of the query's original SQL
      queryPlanCacheEnabled - Designates whether query plans can be cached and reused
      Returns:
      The returning result of the query