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

Summary

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 ...

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