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
-
Method Summary
Modifier and Type Method Description 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.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.List<String>
getCascadingDeleteSql(javax.persistence.EntityManager em, javax.persistence.Query query)
Returns the cascading SQL delete queries for the given query object.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.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.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.String
getSql(javax.persistence.EntityManager em, javax.persistence.Query query)
Returns the SQL query for the given query object.String
getSqlAlias(javax.persistence.EntityManager em, javax.persistence.Query query, String alias)
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
supportsAdvancedSql()
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
-
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
-
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)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 alias- Returns:
- The SQL table alias
-
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
-