14.2. Basic HQL and JPA QL queries

Let's start with some simple queries to get familiar with the HQL syntax and semantics. We apply selection to name the data source, restriction to match records to the criteria, and projection to select the data you want returned from a query.

TRY IT

Testing Hibernate queries—The Hibernate Tools for the Eclipse IDE support a Hibernate Console view. You can test your queries in the console window, and see the generated SQL and the result immediately.

You'll also learn JPA QL in this section, because it's a subset of the functionality of HQL—we'll mention the differences when necessary.

When we talk about queries in this section, we usually mean SELECT statements, operations that retrieve data from the database. ...

Get Java Persistence with Hibernate 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.