Class PreparedQuery<T>
java.lang.Object
com.evolveum.midpoint.schema.query.AbstractTypedQuery<T,PreparedQuery<T>>
com.evolveum.midpoint.schema.query.PreparedQuery<T>
- Type Parameters:
T
-Resulting item type
Prepared Query represents query with filter with placeholders, which can be used for search.
Prepared Query differs from
TypedQuery
that original query contained placeholders, which needs to be bound to actual values
before query is used.
Values could be bound using bindValue(Object)
method for binding first unbound values or by using bind(Object...)
method which binds multiple unbound values in order of their appeareance.
Prepared Query can be converted to TypedQuery
by binding values using bind(Object...)
method. Once prepared query
is successfully bound, filter is cached and new typed queries could be generated using toTypedQuery()
.-
Field Summary
Fields inherited from class com.evolveum.midpoint.schema.query.AbstractTypedQuery
type
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Binds multiple values and returns final Typed Query which will contain filter.Binds next unbound value in filter to provided value.build()
static <T> PreparedQuery<T>
parse
(Class<T> type, ItemDefinition<?> def, String query) static <T> PreparedQuery<T>
Parses supplied query string for type with placeholder support.protected PreparedQuery<T>
self()
Creates newTypedQuery
based on type, filter, bound values and configuration of paging and ordering.Methods inherited from class com.evolveum.midpoint.schema.query.AbstractTypedQuery
buildObjectPaging, fillFrom, getMaxSize, getOffset, maxSize, offset, operationOptionsBuilder, orderBy, pagingRequired
-
Method Details
-
parse
Parses supplied query string for type with placeholder support.- Type Parameters:
T
- Type of the items which query should return- Parameters:
type
- Type of the items which query should returnquery
- Midpoint Query string without placeholders- Returns:
- new Prepared Query which contains partially parsed filter, type information and allows for values to be bound to placeholders.
- Throws:
SchemaException
- when supplied query string was syntactically or logically incorrect
-
parse
public static <T> PreparedQuery<T> parse(Class<T> type, ItemDefinition<?> def, String query) throws SchemaException - Throws:
SchemaException
-
bindValue
Binds next unbound value in filter to provided value. IMPORTANT: Current behavior is strict in checking value types for bound values, user must supply correct class for realValue (eg.PolyString
,XMLGregorianCalendar
- Parameters:
realValue
- Real Value to be bound- Throws:
SchemaException
- If provided value is invalid according to schema definition (type of value)IllegalStateException
- If there is no positional value to be bound
-
set
- Parameters:
name
-realValue
-- Returns:
- Throws:
SchemaException
-
bind
Binds multiple values and returns final Typed Query which will contain filter.- Parameters:
args
- Real values to be bound to unbound placeholders in order of appearance. SeebindValue(Object)
for more details.- Returns:
- Typed Query which contains final filter and configuration of paging and ordering.
- Throws:
IllegalStateException
- If not all placeholders were bound to valuesSchemaException
- If provided values are invalid according to schema definition (type of value) resulting filter with bound values is invalid.
-
toTypedQuery
Creates newTypedQuery
based on type, filter, bound values and configuration of paging and ordering.- Returns:
- New Typed Query based on bound values and configuration of paging and ordering.
- Throws:
IllegalStateException
- If query was not successfully bound before usingbind(Object...)
orbuild()
.
-
toObjectQuery
-
build
- Returns:
- Throws:
SchemaException
-
allPlaceholdersBound
public boolean allPlaceholdersBound()- Returns:
- True if all placeholders were bound to value.
-
self
- Specified by:
self
in classAbstractTypedQuery<T,
PreparedQuery<T>>
-