Class QueryComposer<T>
Example usage:
tm().createQueryComposer(EntityType.class) .where("fieldName", Comparator.EQ, "value") .orderBy("fieldName") .stream()
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum used to specify comparison operations, e.g.protected static class
QueryComposer.WhereClause<U extends Comparable<? super U>>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract long
count()
Returns the number of results of the query.static <U extends Comparable<? super U>>
CriteriaQueryBuilder.WhereOperator<U> equal
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) first()
Returns the first result of the query or an empty optional if there is none.abstract T
Returns the one and only result of a query.static <U extends Comparable<? super U>>
CriteriaQueryBuilder.WhereOperator<U> greaterThan
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) static <U extends Comparable<? super U>>
CriteriaQueryBuilder.WhereOperator<U> greaterThanOrEqualTo
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) static <U extends Comparable<? super U>>
CriteriaQueryBuilder.WhereOperator<U> lessThan
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) static <U extends Comparable<? super U>>
CriteriaQueryBuilder.WhereOperator<U> lessThanOrEqualTo
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) like
(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) abstract com.google.common.collect.ImmutableList
<T> list()
Returns the results of the query as a list.Order the query results by the value of the specified field.stream()
Returns the results of the query as a stream.<U extends Comparable<? super U>>
QueryComposer<T> where
(String fieldName, QueryComposer.Comparator comparator, U value) Introduce a "where" clause to the query.withFetchSize
(int fetchSize) AppliesfetchSize
to the JDBC statement (by callingStatement.setFetchSize(int)
) if the query result is accessed by thestream()
method.
-
Field Details
-
entityClass
-
orderBy
-
predicates
-
-
Constructor Details
-
QueryComposer
-
-
Method Details
-
where
public <U extends Comparable<? super U>> QueryComposer<T> where(String fieldName, QueryComposer.Comparator comparator, U value) Introduce a "where" clause to the query.Causes the query to return only results where the field and value have the relationship specified by the comparator. For example, "field EQ value", "field GT value" etc.
-
orderBy
Order the query results by the value of the specified field.TODO: add the ability to do descending sort order.
-
withFetchSize
AppliesfetchSize
to the JDBC statement (by callingStatement.setFetchSize(int)
) if the query result is accessed by thestream()
method. Calling this method is optional. Children of this class will apply a default positive fetch size if the user does not provide one.With many JDBC drivers, including Postgresql, a positive fetch size is required for streaming large result sets. A zero value, often the drivers' default setting, requires that the entire result set is buffered.
The fetch size value, the default as well as the user-provided one, will be applied if and only if the underlying query implementor supports it. The Hibernate implementations do support this.
-
first
Returns the first result of the query or an empty optional if there is none. -
getSingleResult
Returns the one and only result of a query.Throws a
NonUniqueResultException
if there is more than one result, throwsNoResultException
if no results are found. -
stream
Returns the results of the query as a stream. -
count
public abstract long count()Returns the number of results of the query. -
list
Returns the results of the query as a list. -
equal
public static <U extends Comparable<? super U>> CriteriaQueryBuilder.WhereOperator<U> equal(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) -
lessThan
public static <U extends Comparable<? super U>> CriteriaQueryBuilder.WhereOperator<U> lessThan(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) -
lessThanOrEqualTo
public static <U extends Comparable<? super U>> CriteriaQueryBuilder.WhereOperator<U> lessThanOrEqualTo(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) -
greaterThanOrEqualTo
public static <U extends Comparable<? super U>> CriteriaQueryBuilder.WhereOperator<U> greaterThanOrEqualTo(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) -
greaterThan
public static <U extends Comparable<? super U>> CriteriaQueryBuilder.WhereOperator<U> greaterThan(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder) -
like
public static CriteriaQueryBuilder.WhereOperator<String> like(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder)
-