@java.lang.SuppressWarnings({"rawtypes", "unchecked"}) public abstract class Query extends java.lang.Object
Models a query that can be executed against a data store.
Modifiers | Name | Description |
---|---|---|
static class |
Query.AvgProjection |
Computes the average value of a property |
static class |
Query.Between |
Criterion used to restrict the result to be between values (range query) |
static class |
Query.Conjunction |
A Criterion used to combine to criterion in a logical AND |
static class |
Query.CountDistinctProjection |
|
static class |
Query.CountProjection |
Used to count the results of a query |
static interface |
Query.Criterion |
Represents a criterion to be used in a criteria query |
static class |
Query.Disjunction |
A Criterion used to combine to criterion in a logical OR |
static class |
Query.DistinctProjection |
|
static class |
Query.DistinctPropertyProjection |
|
static class |
Query.Equals |
A criterion that restricts the results based on equality |
static class |
Query.EqualsAll |
Restricts a value to be equal to all the given values |
static class |
Query.EqualsProperty |
|
static class |
Query.Exists |
Used for exists subquery |
static class |
Query.GreaterThan |
Used to restrict a value to be greater than the given value |
static class |
Query.GreaterThanAll |
Restricts a value to be greater than all the given values |
static class |
Query.GreaterThanEquals |
Used to restrict a value to be greater than or equal to the given value |
static class |
Query.GreaterThanEqualsAll |
Restricts a value to be greater than or equal to all the given values |
static class |
Query.GreaterThanEqualsProperty |
|
static class |
Query.GreaterThanEqualsSome |
Restricts a value to be greater than some of the given values |
static class |
Query.GreaterThanProperty |
|
static class |
Query.GreaterThanSome |
Restricts a value to be greater than some of the given values |
static class |
Query.GroupPropertyProjection |
|
static class |
Query.ILike |
Criterion used to restrict the results based on a pattern (likeness) |
static class |
Query.IdEquals |
A criterion that restricts the results based on the equality of the identifier |
static class |
Query.IdProjection |
A projection used to obtain the identifier of an object |
static class |
Query.In |
Criterion used to restrict the results based on a list of values |
static class |
Query.IsEmpty |
Restricts a property to be empty (such as a blank string) |
static class |
Query.IsNotEmpty |
Restricts a property to be empty (such as a blank string) |
static class |
Query.IsNotNull |
Restricts a property to be not null |
static class |
Query.IsNull |
Models a query that can be executed against a data store. |
static class |
Query.Junction |
|
static class |
Query.LessThan |
Used to restrict a value to be less than the given value |
static class |
Query.LessThanAll |
Restricts a value to be less than all the given values |
static class |
Query.LessThanEquals |
Used to restrict a value to be less than the given value |
static class |
Query.LessThanEqualsAll |
Restricts a value to be less than or equal to all the given values |
static class |
Query.LessThanEqualsProperty |
|
static class |
Query.LessThanEqualsSome |
Restricts a value to be less than some of the given values |
static class |
Query.LessThanProperty |
|
static class |
Query.LessThanSome |
Restricts a value to be less than some of the given values |
static class |
Query.Like |
Criterion used to restrict the results based on a pattern (likeness) |
static class |
Query.MaxProjection |
Computes the max value of a property |
static class |
Query.MinProjection |
Computes the min value of a property |
static class |
Query.Negation |
A criterion used to negate several other criterion |
static class |
Query.NotEquals |
A criterion that restricts the results based on equality |
static class |
Query.NotEqualsAll |
Restricts a value to be not equal to all the given values |
static class |
Query.NotEqualsProperty |
|
static class |
Query.NotExists |
Used for exists subquery |
static class |
Query.NotIn |
Criterion used to restrict the results based on a list of values |
static class |
Query.Order |
The ordering of results. |
static class |
Query.Projection |
A projection |
static class |
Query.ProjectionList |
A list of projections |
static class |
Query.PropertyComparisonCriterion |
A Criterion that compares to properties |
static class |
Query.PropertyCriterion |
Criterion that applies to a property and value |
static class |
Query.PropertyNameCriterion |
A Criterion that applies to a property |
static class |
Query.PropertyProjection |
A projection that obtains the value of a property of an entity |
static class |
Query.RLike |
Criterion used to restrict the results based on a regular expression pattern |
static class |
Query.SizeEquals |
|
static class |
Query.SizeGreaterThan |
|
static class |
Query.SizeGreaterThanEquals |
|
static class |
Query.SizeLessThan |
|
static class |
Query.SizeLessThanEquals |
|
static class |
Query.SizeNotEquals |
|
static class |
Query.SubqueryCriterion |
Used to differentiate criterion that require a subquery |
static class |
Query.SumProjection |
Computes the sum of a property |
Modifiers | Name | Description |
---|---|---|
protected Query.Junction |
criteria |
|
protected PersistentEntity |
entity |
|
protected java.util.Map<java.lang.String, javax.persistence.FetchType> |
fetchStrategies |
|
protected javax.persistence.LockModeType |
lockResult |
|
protected int |
max |
|
protected int |
offset |
|
protected java.util.List<Order> |
orderBy |
|
protected Query.ProjectionList |
projections |
|
protected java.lang.Boolean |
queryCache |
|
protected Session |
session |
|
protected boolean |
uniqueResult |
Constructor and description |
---|
protected Query
(Session session, PersistentEntity entity) |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
add(Query.Criterion criterion) Adds the specified criterion instance to the query |
|
void |
add(Query.Junction currentJunction, Query.Criterion criterion) Adds the specified criterion instance to the given junction |
|
Query |
allEq(java.util.Map<java.lang.String, java.lang.Object> values) Shortcut to restrict the query to multiple given property values |
|
Query |
and(Query.Criterion a, Query.Criterion b) Creates a conjunction using two specified criterion |
|
Query |
between(java.lang.String property, java.lang.Object start, java.lang.Object end) Restricts the results by the given property value range |
|
Query |
cache(boolean cache) Specifies whether the query results should be cached (if supported by the underlying datastore) |
|
java.lang.Object |
clone() |
|
Query.Junction |
conjunction() Creates a conjunction (AND) query |
|
AssociationQuery |
createQuery(java.lang.String associationName) Creates an association query |
|
Query.Junction |
disjunction() Creates a disjunction (OR) query |
|
Query |
eq(java.lang.String property, java.lang.Object value) Restricts the results by the given properties value |
|
protected java.util.List |
executeQuery(PersistentEntity entity, Query.Junction criteria) Subclasses should implement this to provide the concrete implementation of querying |
|
protected javax.persistence.FetchType |
fetchStrategy(java.lang.String property) Obtain the fetch strategy for the given property |
|
Query |
firstResult(int offset) Defines the offset (the first result index) of the query |
|
protected void |
flushBeforeQuery() Default behavior is the flush the session before a query in the case of FlushModeType.AUTO. |
|
Query |
ge(java.lang.String property, java.lang.Object value) Used to restrict a value to be greater than or equal to the given value |
|
Query.Junction |
getCriteria() @return The criteria defined by this query |
|
PersistentEntity |
getEntity() @return The PersistentEntity being query |
|
java.util.List<Order> |
getOrderBy() Gets the Order entries for this query |
|
Session |
getSession() @return The session that created the query |
|
Query |
gt(java.lang.String property, java.lang.Object value) Used to restrict a value to be greater than the given value |
|
Query |
gte(java.lang.String property, java.lang.Object value) Used to restrict a value to be greater than or equal to the given value |
|
Query |
idEq(java.lang.Object value) Restricts the results by the given properties value |
|
Query |
ilike(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
Query |
in(java.lang.String property, java.util.List values) Restricts the results by the given property values |
|
Query |
isEmpty(java.lang.String property) Used to restrict a value to be empty (such as a blank string or an empty collection) |
|
Query |
isNotEmpty(java.lang.String property) Used to restrict a value to be not empty (such as a blank string or an empty collection) |
|
Query |
isNotNull(java.lang.String property) Used to restrict a property to be not null |
|
Query |
isNull(java.lang.String property) Used to restrict a property to be null |
|
Query |
join(java.lang.String property) Specifies whether a join query should be used (if join queries are supported by the underlying datastore) |
|
Query |
le(java.lang.String property, java.lang.Object value) Used to restrict a value to be less than or equal to the given value |
|
Query |
like(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
java.util.List |
list() Executes the query returning zero or many results as a list. |
|
Query |
lock(boolean lock) Specifies whether the query should obtain a pessimistic lock |
|
Query |
lock(javax.persistence.LockModeType lock) Specifies whether the query should obtain a pessimistic lock |
|
Query |
lt(java.lang.String property, java.lang.Object value) Used to restrict a value to be less than the given value |
|
Query |
lte(java.lang.String property, java.lang.Object value) Used to restrict a value to be less than or equal to the given value |
|
Query |
max(int max) Defines the maximum number of results to return |
|
Query |
maxResults(int max) Defines the maximum number of results to return |
|
Query.Junction |
negation() Creates a negation of several criterion |
|
Query |
offset(int offset) Defines the offset (the first result index) of the query |
|
Query |
or(Query.Criterion a, Query.Criterion b) Creates a disjunction using two specified criterion |
|
Query |
order(Query.Order order) Specifies the order of results |
|
static java.lang.String |
patternToRegex(java.lang.Object value) Converts a pattern to regex for regex queruies |
|
Query.ProjectionList |
projections() |
|
protected java.lang.Object |
resolveIdIfEntity(java.lang.Object value) |
|
Query |
rlike(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
Query |
select(java.lang.String property) Specifies whether a select (lazy) query should be used (if join queries are supported by the underlying datastore) |
|
void |
setUniqueResult(boolean uniqueResult) Here purely for compatibility |
|
java.lang.Object |
singleResult() Executes the query returning a single result or null |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Adds the specified criterion instance to the query
criterion
- The criterion instanceAdds the specified criterion instance to the given junction
currentJunction
- The junction to add the criterion tocriterion
- The criterion instanceShortcut to restrict the query to multiple given property values
values
- The valuesCreates a conjunction using two specified criterion
a
- The left hand sideb
- The right hand sideRestricts the results by the given property value range
property
- The name of the propertystart
- The start of the rangeend
- The end of the rangeSpecifies whether the query results should be cached (if supported by the underlying datastore)
cache
- True if caching should be enabledCreates a conjunction (AND) query
Creates an association query
associationName
- The assocation nameCreates a disjunction (OR) query
Restricts the results by the given properties value
property
- The name of the propertyvalue
- The value to restrict bySubclasses should implement this to provide the concrete implementation of querying
entity
- The entitycriteria
- The criteriaObtain the fetch strategy for the given property
property
- The fetch strategyDefines the offset (the first result index) of the query
offset
- The offsetDefault behavior is the flush the session before a query in the case of FlushModeType.AUTO. Subclasses can override this method to disable that.
Used to restrict a value to be greater than or equal to the given value
property
- The name of the propertyvalue
- The value to restrict by
Gets the Order entries for this query
Used to restrict a value to be greater than the given value
property
- The name of the propertyvalue
- The value to restrict byUsed to restrict a value to be greater than or equal to the given value
property
- The name of the propertyvalue
- The value to restrict byRestricts the results by the given properties value
value
- The value to restrict byRestricts the results by the given properties value
property
- The name of the propertyexpr
- The expression to restrict byRestricts the results by the given property values
property
- The name of the propertyvalues
- The values to restrict byUsed to restrict a value to be empty (such as a blank string or an empty collection)
property
- The property nameUsed to restrict a value to be not empty (such as a blank string or an empty collection)
property
- The property nameUsed to restrict a property to be not null
property
- The property nameUsed to restrict a property to be null
property
- The property nameSpecifies whether a join query should be used (if join queries are supported by the underlying datastore)
property
- The propertyUsed to restrict a value to be less than or equal to the given value
property
- The name of the propertyvalue
- The value to restrict byRestricts the results by the given properties value
property
- The name of the propertyexpr
- The expression to restrict byExecutes the query returning zero or many results as a list.
Specifies whether the query should obtain a pessimistic lock
lock
- True if a lock should be obtainedSpecifies whether the query should obtain a pessimistic lock
lock
- True if a lock should be obtainedUsed to restrict a value to be less than the given value
property
- The name of the propertyvalue
- The value to restrict byUsed to restrict a value to be less than or equal to the given value
property
- The name of the propertyvalue
- The value to restrict byDefines the maximum number of results to return
max
- The max resultsDefines the maximum number of results to return
max
- The max resultsCreates a negation of several criterion
Defines the offset (the first result index) of the query
offset
- The offsetCreates a disjunction using two specified criterion
a
- The left hand sideb
- The right hand sideSpecifies the order of results
order
- The order objectConverts a pattern to regex for regex queruies
value
- The valueRestricts the results by the given properties value
property
- The name of the propertyexpr
- The expression to restrict bySpecifies whether a select (lazy) query should be used (if join queries are supported by the underlying datastore)
property
- The propertyHere purely for compatibility
uniqueResult
- Whether it is a unique resultExecutes the query returning a single result or null