Class CriteriaQueryBuilder<T>
- java.lang.Object
-
- google.registry.persistence.transaction.CriteriaQueryBuilder<T>
-
public class CriteriaQueryBuilder<T> extends java.lang.Object
An extension ofCriteriaQuery
that uses a Builder-style pattern when adding "WHERE" and/or "ORDER BY" clauses.CriteriaQuery
, as is, requires that all clauses must be passed in at once -- if one calls "WHERE" multiple times, the later call overwrites the earlier call.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CriteriaQueryBuilder.WhereOperator<U>
Functional interface that defines the 'where' operator, e.g.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.persistence.criteria.CriteriaQuery<T>
build()
Builds and returns the query, applying all WHERE and ORDER BY clauses at once.static <T> CriteriaQueryBuilder<T>
create(JpaTransactionManager jpaTm, java.lang.Class<T> clazz)
Creates a query builder for the given entity manager.static <T> CriteriaQueryBuilder<T>
create(java.lang.Class<T> clazz)
Creates a query builder that will SELECT from the given class.static <T> CriteriaQueryBuilder<java.lang.Long>
createCount(JpaTransactionManager jpaTm, java.lang.Class<T> clazz)
Creates a "count" query for the table for the class.CriteriaQueryBuilder<T>
orderByAsc(java.lang.String fieldName)
Orders the result by the given field ascending.CriteriaQueryBuilder<T>
orderByDesc(java.lang.String fieldName)
Orders the result by the given field descending.<U> CriteriaQueryBuilder<T>
where(java.lang.String fieldName, CriteriaQueryBuilder.WhereOperator<U> whereClause, U value)
Adds a WHERE clause to the query, given the specified operation, field, and value.CriteriaQueryBuilder<T>
whereFieldContains(java.lang.String fieldName, java.lang.Object value)
Adds a WHERE clause to the query specifying that a collection field must contain a particular value.CriteriaQueryBuilder<T>
whereFieldIsIn(java.lang.String fieldName, java.util.Collection<?> values)
Adds a WHERE clause to the query specifying that a value must be in the given collection.CriteriaQueryBuilder<T>
whereFieldIsNotIn(java.lang.String fieldName, java.util.Collection<?> values)
Adds a WHERE clause to the query specifying that a value must not be in the given collection.
-
-
-
Method Detail
-
where
public <U> CriteriaQueryBuilder<T> where(java.lang.String fieldName, CriteriaQueryBuilder.WhereOperator<U> whereClause, U value)
Adds a WHERE clause to the query, given the specified operation, field, and value.
-
whereFieldIsIn
public CriteriaQueryBuilder<T> whereFieldIsIn(java.lang.String fieldName, java.util.Collection<?> values)
Adds a WHERE clause to the query specifying that a value must be in the given collection.
-
whereFieldIsNotIn
public CriteriaQueryBuilder<T> whereFieldIsNotIn(java.lang.String fieldName, java.util.Collection<?> values)
Adds a WHERE clause to the query specifying that a value must not be in the given collection.
-
whereFieldContains
public CriteriaQueryBuilder<T> whereFieldContains(java.lang.String fieldName, java.lang.Object value)
Adds a WHERE clause to the query specifying that a collection field must contain a particular value.
-
orderByAsc
public CriteriaQueryBuilder<T> orderByAsc(java.lang.String fieldName)
Orders the result by the given field ascending.
-
orderByDesc
public CriteriaQueryBuilder<T> orderByDesc(java.lang.String fieldName)
Orders the result by the given field descending.
-
build
public javax.persistence.criteria.CriteriaQuery<T> build()
Builds and returns the query, applying all WHERE and ORDER BY clauses at once.
-
create
public static <T> CriteriaQueryBuilder<T> create(java.lang.Class<T> clazz)
Creates a query builder that will SELECT from the given class.
-
create
public static <T> CriteriaQueryBuilder<T> create(JpaTransactionManager jpaTm, java.lang.Class<T> clazz)
Creates a query builder for the given entity manager.
-
createCount
public static <T> CriteriaQueryBuilder<java.lang.Long> createCount(JpaTransactionManager jpaTm, java.lang.Class<T> clazz)
Creates a "count" query for the table for the class.
-
-