In this tutorial you will learn about Hibernate Query Language.
HQL is an abbreviation of Hibernate Query Language. It is a powerful query language, inspired by SQL that the Hibernate uses. When looking a HQL it is as similar to SQL but the HQL is different from SQL, HQL is fully object-oriented and it supports inheritance, polymorphism, abstraction. Queries in HQL are case-insensitive excluding the name of classes of java and the properties. for example in query WHerE is as same to whERe but a class name roseindia.net.HibernateExample is not same as roseindia.net.Hibernateexample.
Benefits of Hibernate Query Language is :
In this example I will write a SQL query and a corresponding HQL query which will demonstrate you how a HQL is looking as same as SQL and how both are different. Let's suppose there is a table 'person' with their fields 'Id', 'Name', 'PersonType' having some value.
1. Writing a query in SQL
SELECT name FROM person WHERE id = "4"
2. A corresponding HQL query can be written as :
SELECT per.name FROM person per WHERE per.id = "4"
Some of the common HQL queries statements / clause are :
Each of the above statements / clause is explained individually. In the next section of this tutorial.
Liked it! Share this Tutorial
Ask Questions? Discuss: Introduction To Hibernate Query Language (HQL)
Post your Comment