Java Reference
In-Depth Information
Create method
Description
Creates a new criteria object that will perform a bulk up-
date operation
createCriteriaUpdate( Class<T> targetEntity)
The type of the query indicates the expected return type. It need not be a managed entity.
For example, you'd pass in Long.class if the result of the expression computed the
average of all bids on a particular item. Alternatively, as you'll see when we cover the
SELECT statement, you can specify a wrapper object that's not a managed entity at all but
is instead populated from the results.
The CriteriaBuilder also provides factory methods for creating expressions, order
statements, selection statements, and predicates. The methods are shown in table 11.11 .
We'll cover these in more detail in the subsequent sessions.
Table 11.11. CriteriaBuilder methods grouped by type
Type
Methods
abs, all, any, avg, coalesce, concat, construct, count, countDistinct, currentDate, currentTime, cur-
rentTimestamp, diff, function, greatest, keys, least, length, literal, locate, lower, max, min, mod,
neg, nullif, nullLiteral, parameter, prod, quot, selectCase, size, some, sqrt, substring, sum,
sumAsDouble, sumAsLong, toBigDecimal, toBigInteger, toDouble, toFloat, toInteger, toLong,
toString, trim, upper, values
Expression
Selection
array, construct, tuple
Ordering
asc, desc
and, between, conjunction, disjunction, equal, exists, ge, greaterThan, greaterThanOrEqualTo, gt,
in, isEmpty, isFalse, isMember, isNotEmpty, isNotMember, isNotNull, isNull, isTrue, le, lessThan,
lessThanOrEqualTo, like, lt, not, notEqual, notLike, or
Predicate
11.2.3. CriteriaQuery
The CriteriaQuery object is the heart of the criteria API. It pulls together all the pieces
of a query: SELECT , FROM , and the optional WHERE clause to create an object represent-
ation of an SQL query. Under the hood, JPA uses this object representation to generate an
SQL statement. JPA executes this statement against the database and then repackages the
result into the object form that you specified when you created the query. This isn't very
different from JPQL except that you're building the object representation manually instead
of having JPA validate and convert a freeform query into an object representation.
 
Search WWH ::




Custom Search