@java.lang.SuppressWarnings({"rawtypes", "unchecked"}) public abstract class Query extends java.lang.Object implements java.lang.Cloneable
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 |
Restricts a property to be null |
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 Junction |
criteria |
|
protected PersistentEntity |
entity |
|
protected java.util.Map<java.lang.String, javax.persistence.FetchType> |
fetchStrategies |
|
protected java.util.Map<java.lang.String, javax.persistence.criteria.JoinType> |
joinTypes |
|
protected javax.persistence.LockModeType |
lockResult |
|
protected int |
max |
|
protected int |
offset |
|
protected java.util.List<Order> |
orderBy |
|
protected 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 |
---|---|---|
|
public void |
add(org.hibernate.criterion.Criterion criterion) Adds the specified criterion instance to the query |
|
public void |
add(Junction currentJunction, org.hibernate.criterion.Criterion criterion) Adds the specified criterion instance to the given junction |
|
public Query |
allEq(java.util.Map<java.lang.String, java.lang.Object> values) Shortcut to restrict the query to multiple given property values |
|
public Query |
and(org.hibernate.criterion.Criterion a, org.hibernate.criterion.Criterion b) Creates a conjunction using two specified criterion |
|
public Query |
between(java.lang.String property, java.lang.Object start, java.lang.Object end) Restricts the results by the given property value range |
|
public Query |
cache(boolean cache) Specifies whether the query results should be cached (if supported by the underlying datastore) |
|
public java.lang.Object |
clone() |
|
public Junction |
conjunction() Creates a conjunction (AND) query |
|
public AssociationQuery |
createQuery(java.lang.String associationName) Creates an association query |
|
public Junction |
disjunction() Creates a disjunction (OR) query |
|
public Query |
eq(java.lang.String property, java.lang.Object value) Restricts the results by the given properties value |
|
protected abstract java.util.List |
executeQuery(PersistentEntity entity, 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 |
|
public 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. |
|
public 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 |
|
public Junction |
getCriteria()
|
|
public PersistentEntity |
getEntity()
|
|
public java.util.List<Order> |
getOrderBy() Gets the Order entries for this query |
|
public Session |
getSession()
|
|
public Query |
gt(java.lang.String property, java.lang.Object value) Used to restrict a value to be greater than the given value |
|
public 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 |
|
public Query |
idEq(java.lang.Object value) Restricts the results by the given properties value |
|
public Query |
ilike(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
public Query |
in(java.lang.String property, java.util.List values) Restricts the results by the given property values |
|
public Query |
isEmpty(java.lang.String property) Used to restrict a value to be empty (such as a blank string or an empty collection) |
|
public Query |
isNotEmpty(java.lang.String property) Used to restrict a value to be not empty (such as a blank string or an empty collection) |
|
public Query |
isNotNull(java.lang.String property) Used to restrict a property to be not null |
|
public Query |
isNull(java.lang.String property) Used to restrict a property to be null |
|
public Query |
join(java.lang.String property) Specifies whether a join query should be used (if join queries are supported by the underlying datastore) |
|
public Query |
join(java.lang.String property, javax.persistence.criteria.JoinType joinType) Specifies whether a join query should be used (if join queries are supported by the underlying datastore) |
|
public 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 |
|
public Query |
like(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
public java.util.List |
list() Executes the query returning zero or many results as a list. |
|
public Query |
lock(boolean lock) Specifies whether the query should obtain a pessimistic lock |
|
public Query |
lock(javax.persistence.LockModeType lock) Specifies whether the query should obtain a pessimistic lock |
|
public Query |
lt(java.lang.String property, java.lang.Object value) Used to restrict a value to be less than the given value |
|
public 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 |
|
public Query |
max(int max) Defines the maximum number of results to return |
|
public Query |
maxResults(int max) Defines the maximum number of results to return |
|
public Junction |
negation() Creates a negation of several criterion |
|
public Query |
offset(int offset) Defines the offset (the first result index) of the query |
|
public Query |
or(org.hibernate.criterion.Criterion a, org.hibernate.criterion.Criterion b) Creates a disjunction using two specified criterion |
|
public Query |
order(Order order) Specifies the order of results |
|
public static java.lang.String |
patternToRegex(java.lang.Object value) Converts a pattern to regex for regex queruies |
|
public ProjectionList |
projections() |
|
protected java.lang.Object |
resolveIdIfEntity(java.lang.Object value) |
|
public Query |
rlike(java.lang.String property, java.lang.String expr) Restricts the results by the given properties value |
|
public Query |
select(java.lang.String property) Specifies whether a select (lazy) query should be used (if join queries are supported by the underlying datastore) |
|
public void |
setUniqueResult(boolean uniqueResult) Here purely for compatibility |
|
public 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(), java.lang.Object#wait(long), 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 propertySpecifies 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