O'Reilly logo

Beginning Hibernate: From Novice to Professional by Jeff Linwood, Dave Minter

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

CHAPTER 10Advanced QueriesUsing Criteria

Hibernate provides three different ways to retrieve data. We have already discussed HQL and the use of native SQL queries—now we add criteria.

The Criteria Query API lets you build nested, structured query expressions in Java, providing a compile-time syntax-checking that is not possible with a query language like HQL or SQL. The Criteria API also includes query by example (QBE) functionality—this lets you supply example objects that contain the properties you would like to retrieve instead of having to spell the components of the query out step by step. It also includes projection and aggregation methods, including counts.

In this chapter, we explore the use of the Criteria API using the sample database ...

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