From the course: Java Persistence API (JPA): 2 Inheritance and Querying
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Restrict criteria query results
From the course: Java Persistence API (JPA): 2 Inheritance and Querying
Restrict criteria query results
- [Instructor] Let's learn about restricting query results using the where clause of the Criteria API. We will also learn about the conditional methods you can use with CriteriaBuilder objects. The results of a query can be restricted on the CriteriaObject according to conditions set by calling the CriteriaQuery where method. Calling the where method is just like setting the where clause in a JPQL query. The where method accepts a single expression Boolean argument or either zero or more predicate objects. Each call to where causes any previously set where expressions to be discarded and replaced with the newly passed in ones. The CriteriaBuilder interface defines additional methods for creating expressions. These methods correspond to the arithmetic, string, date, time, and case operators and functions of JPQL. There are several conditional methods you can use with CriteriaBuilder objects such as equal, NotEqual, greater than, greater than equal, et cetera. There are several compound…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.