Package com.blazebit.persistence.spi
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
Modifier and TypeInterfaceDescriptionstatic interface
Provides SQL information about a FROM element. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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 ofgetSql(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 resultsfirstResult
- The first result to applymaxResults
- The max results to apply- Returns:
- Whether firstResult or maxResult was set or unset whereas before it wasn't
- Since:
- 1.6.7
-
getSql
Returns the SQL query for the given query object.- Parameters:
em
- The entity manager the query is associated toquery
- The JPA query- Returns:
- The SQL query
-
getSqlContainsLimit
boolean getSqlContainsLimit()Returns whether the return ofgetSql(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 toquery
- 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 toquery
- The JPA queryalias
- The from node aliasqueryPartNumber
- 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 toquery
- The JPA queryalias
- The from node aliasqueryPartNumber
- 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 toquery
- The JPA queryalias
- 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 toquery
- The JPA queryattribute
- 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 othersparticipatingQueries
- The list of participating queries from which to combine parametersquery
- The main query to executesqlOverride
- The actual SQL query to execute instead of the query's original SQLqueryPlanCacheEnabled
- 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 othersparticipatingQueries
- The list of participating queries from which to combine parametersquery
- The main query to executesqlOverride
- The actual SQL query to execute instead of the query's original SQLqueryPlanCacheEnabled
- 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 othersparticipatingQueries
- The list of participating queries from which to combine parametersquery
- The main query to executesqlOverride
- The actual SQL query to execute instead of the query's original SQLqueryPlanCacheEnabled
- 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 othersparticipatingQueries
- The list of participating queries from which to combine parametersbaseQuery
- The base query which represents the original modification queryquery
- The main query to executesqlOverride
- The actual SQL query to execute instead of the query's original SQLqueryPlanCacheEnabled
- 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 othersparticipatingQueries
- The list of participating queries from which to combine parametersbaseQuery
- The base query which represents the original modification queryexampleQuery
- The example query providing the result type structuresqlOverride
- The actual SQL query to execute instead of the query's original SQLqueryPlanCacheEnabled
- Designates whether query plans can be cached and reused- Returns:
- The returning result of the query
-