Hibernate Query Language or HQL for short is extremely powerful query language. HQL is much like SQL and are case-insensitive, except for the names of the Java Classes and properties. Hibernate Query Language is used to execute queries against database. Hibernate automatically generates the sql query and execute it against underlying database if HQL is used in the application. HQL is based on the relational object models and makes the SQL object oriented. Hibernate Query Language uses Classes and properties instead of tables and columns. Hibernate Query Language is extremely powerful and it supports Polymorphism, Associations, Much less verbose than SQL.
There are other options that can be used while using Hibernate. These are Query By Criteria (QBC) and Query BY Example (QBE) using Criteria API and the Native SQL queries. In this lesson we will understand HQL in detail.
Why to use HQL?
Understanding HQL Syntax
Any Hibernate Query Language may consist of following elements:
Clauses in the HQL are:
Aggregate functions are:
Subqueries are nothing but its a query within another query. Hibernate supports Subqueries if the underlying database supports it.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: January 19, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles