In this chapter, we discussed querying in Hibernate. Hibernate provides three distinct ways to query the persistent objects: HQL, native SQL, and the Criteria API.

HQL is an SQL-like language that, unlike SQL (which works on raw data in the database), lets us express queries in an object-oriented form. Like SQL, HQL is not case-sensitive, but Java-related words, such as class and property names, should appear in the correct case.

The simplest form of HQL starts with a from clause. A where clause can be added to the end of a from clause to restrict the query with constraints.

Hibernate lets us query persistent objects with native SQL. To execute a native SQL query, you can pass the query expression to the createSQLQuery() method of Session ...

Get Spring Persistence with Hibernate now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.