O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Criteria API

The Criteria API is another approach to querying persistent objects. This API lets us build query expressions programmatically through Java objects. It provides compile-time syntax checking, rather than runtime processing (which is provided by HQL).

The Criteria API provides a unique Query By Example (QBE) functionality that is not provided by other query approaches. Using QBE, you can create an instance of the queried class, and set the instance's properties with the values that you want the result to have. The result of the query is all persistent objects that match the instance.

In general, the Criteria approach is less flexible and less powerful than HQL. Criteria queries are less readable and harder to understand than ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required