Interface Query<T>
- Type Parameters:
T- mapped entity type
public interface Query<T>
A mutable, parameterized query obtained from
Session.query(Class).
Uses Java attribute names and joins relationship paths as needed. Predicates are
combined with AND. Execution flushes pending changes in an active transaction.
Keep the owning session open; queries are not thread-safe. Applications should
not implement this interface.-
Method Summary
Modifier and TypeMethodDescriptioncontainsElement(String field, Object value) Adds a scalar collection membership predicate without loading the collection.longcount()Counts matching root entities, ignoring ordering and pagination.Adds an equality predicate; null matches SQL NULL.Initializes a direct relationship for returned entities, overriding lazy mapping.first()Executes the query for at most one result, respecting the offset.Adds a greater-than-or-equal predicate.Adds a greater-than predicate.Adds an IN predicate; an empty array matches no rows.Adds an IS NOT NULL predicate.Adds an IS NULL predicate.Adds an inner join on a relationship path.Adds a less-than-or-equal predicate.Adds a left join before the path is used in predicates.Adds a SQL LIKE predicate.limit(int value) Sets the maximum number of results; zero returns no rows.list()Executes the query, applying pagination and fetch requests.Adds a less-than predicate.Adds an inequality predicate; null matches SQL IS NOT NULL.offset(int value) Sets the number of leading results to skip.Appends an ordering term.
-
Method Details
-
join
-
leftJoin
-
fetch
-
containsElement
-
eq
-
ne
-
gt
-
ge
-
lt
-
le
-
like
-
isNull
-
isNotNull
-
in
-
orderBy
-
limit
Sets the maximum number of results; zero returns no rows.- Parameters:
value- nonnegative result limit- Returns:
- this query
- Throws:
IllegalArgumentException- if value is negative
-
offset
Sets the number of leading results to skip.- Parameters:
value- nonnegative result offset- Returns:
- this query
- Throws:
IllegalArgumentException- if value is negative
-
list
-
first
T first()Executes the query for at most one result, respecting the offset.- Returns:
- the first managed entity, or null if no match or the limit is zero
-
count
long count()Counts matching root entities, ignoring ordering and pagination.- Returns:
- number of distinct matching entities
-