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.
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: February 24, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles