© Joseph B. Ottinger, Jeff Linwood and Dave Minter 2016

Joseph B. Ottinger, Jeff Linwood and Dave Minter, Beginning Hibernate, 10.1007/978-1-4842-2319-2_10

10. Advanced Queries Using Criteria

Joseph B. Ottinger, Jeff Linwood2 and Dave Minter3

(1)Youngsville, North Carolina, USA

(2)Austin, Texas, USA

(3)London, UK

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

A criteria query uses a model of the information you’re interested in finding. For example, if you were interested in Customer objects whose first name matched “John,” you’d build a Customer object, set the first name to “John,” and use that model object for the query.

This lets you build nested, structured ...

Get Beginning Hibernate: For Hibernate 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.