Class SqlQueryContext<S,Q extends FlexibleRelationalPathBase<R>,R>
- java.lang.Object
-
- com.evolveum.midpoint.repo.sql.pure.SqlPathContext<S,Q,R>
-
- com.evolveum.midpoint.repo.sql.pure.SqlQueryContext<S,Q,R>
-
- Type Parameters:
S
- schema type, used by encapsulated mappingQ
- type of entity pathR
- row type related to theSqlQueryContext
- All Implemented Interfaces:
FilterProcessor<ObjectFilter>
public class SqlQueryContext<S,Q extends FlexibleRelationalPathBase<R>,R> extends SqlPathContext<S,Q,R> implements FilterProcessor<ObjectFilter>
Context information about SQL query. Works as a kind of accumulator where information are added as the object query is interpreted. It is also used as an entry point forFilterProcessor
processing for this query. And finally, it also executes the query, because this way it is more practical to contain all the needed parametrized types without using Class-type parameters.This object does not handle SQL connections or transaction in any way, any connection needed is provided from the outside.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PAGE_SIZE
Default page size if pagination is requested, that is offset is set, but maxSize is not.static int
MAX_ID_IN_FOR_TO_MANY_FETCH
Number of values (identifiers) used in the IN clause to-many fetching selects.static long
NO_PAGINATION_LIMIT
If no other limit is used for query this limit will be used for sanity reasons.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
executeCount(Connection conn)
PageOf<com.querydsl.core.Tuple>
executeQuery(Connection conn)
Returns page of results with each row represented by a Tuple containingSqlQueryContext
and then individual paths for extension columns, seeQueryModelMapping.extensionColumns
.static <S,Q extends FlexibleRelationalPathBase<R>,R>
SqlQueryContext<S,Q,R>from(Class<S> schemaType, PrismContext prismContext, com.querydsl.sql.Configuration querydslConfiguration)
<DQ extends FlexibleRelationalPathBase<DR>,DR>
SqlQueryContext<?,DQ,DR>leftJoin(DQ newPath, @NotNull BiFunction<Q,DQ,com.querydsl.core.types.Predicate> joinOnPredicateFunction)
Adds new LEFT JOIN to the query and returnsSqlQueryContext
for this join path.com.querydsl.sql.SQLQuery<?>
newQuery(Connection conn)
com.querydsl.core.types.Predicate
process(ObjectFilter filter)
void
processObjectPaging(ObjectPaging paging)
This takes care ofObjectPaging
which includes ordering.void
processOptions(Collection<SelectorOptions<GetOperationOptions>> options)
Q
root()
<T extends FlexibleRelationalPathBase<?>>
Troot(Class<T> rootType)
com.querydsl.sql.SQLQuery<?>
sqlQuery()
Returns wrapped query if usage of Querydsl API is more convenient.PageOf<S>
transformToSchemaType(PageOf<com.querydsl.core.Tuple> result)
Transforms result page with (bean + extension columns) tuple to schema type.String
uniqueAliasName(String baseAliasName)
-
Methods inherited from class com.evolveum.midpoint.repo.sql.pure.SqlPathContext
createItemFilterProcessor, isNotFilterUsed, mapping, markNotFilterUsage, path, path, prismContext
-
-
-
-
Field Detail
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE
Default page size if pagination is requested, that is offset is set, but maxSize is not.- See Also:
- Constant Field Values
-
NO_PAGINATION_LIMIT
public static final long NO_PAGINATION_LIMIT
If no other limit is used for query this limit will be used for sanity reasons.- See Also:
- Constant Field Values
-
MAX_ID_IN_FOR_TO_MANY_FETCH
public static final int MAX_ID_IN_FOR_TO_MANY_FETCH
Number of values (identifiers) used in the IN clause to-many fetching selects. This works effectively as factor of how bad N+1 select is, it's at most N/this-limit+1 bad. For obvious reasons, this works only for non-composite PKs (IDs) on the master entity.- See Also:
- Constant Field Values
-
-
Method Detail
-
from
public static <S,Q extends FlexibleRelationalPathBase<R>,R> SqlQueryContext<S,Q,R> from(Class<S> schemaType, PrismContext prismContext, com.querydsl.sql.Configuration querydslConfiguration)
-
root
public Q root()
-
root
public <T extends FlexibleRelationalPathBase<?>> T root(Class<T> rootType)
-
process
public com.querydsl.core.types.Predicate process(ObjectFilter filter) throws QueryException
- Specified by:
process
in interfaceFilterProcessor<S>
- Throws:
QueryException
-
processObjectPaging
public void processObjectPaging(ObjectPaging paging) throws QueryException
This takes care ofObjectPaging
which includes ordering.- Throws:
QueryException
-
newQuery
public com.querydsl.sql.SQLQuery<?> newQuery(Connection conn)
-
executeQuery
public PageOf<com.querydsl.core.Tuple> executeQuery(Connection conn) throws QueryException
Returns page of results with each row represented by a Tuple containingSqlQueryContext
and then individual paths for extension columns, seeQueryModelMapping.extensionColumns
.- Throws:
QueryException
-
executeCount
public int executeCount(Connection conn)
-
leftJoin
public <DQ extends FlexibleRelationalPathBase<DR>,DR> SqlQueryContext<?,DQ,DR> leftJoin(@NotNull DQ newPath, @NotNull @NotNull BiFunction<Q,DQ,com.querydsl.core.types.Predicate> joinOnPredicateFunction)
Adds new LEFT JOIN to the query and returnsSqlQueryContext
for this join path.- Specified by:
leftJoin
in classSqlPathContext<S,Q extends FlexibleRelationalPathBase<R>,R>
- Type Parameters:
DQ
- query type for the JOINed tableDR
- row type related to theSqlQueryContext
- Parameters:
newPath
- entity path representing the JOIN (must be pre-created with unique alias)joinOnPredicateFunction
- bi-function producing ON predicate for the JOIN
-
uniqueAliasName
public String uniqueAliasName(String baseAliasName)
- Specified by:
uniqueAliasName
in classSqlPathContext<S,Q extends FlexibleRelationalPathBase<R>,R>
-
processOptions
public void processOptions(Collection<SelectorOptions<GetOperationOptions>> options)
-
transformToSchemaType
public PageOf<S> transformToSchemaType(PageOf<com.querydsl.core.Tuple> result) throws SchemaException, QueryException
Transforms result page with (bean + extension columns) tuple to schema type.- Throws:
SchemaException
QueryException
-
sqlQuery
public com.querydsl.sql.SQLQuery<?> sqlQuery()
Returns wrapped query if usage of Querydsl API is more convenient.
-
-