Hibernate HQL Query Language
Hibernate HQL Query Language is one of the query language in the form object object relation mapping query.
In the hibernate data base operations are two types they are
- Single row operations
- Bulk operations
By using save(), load(), update() method, we can perform single row operation.
In hibernate there are three ways to perform bulk operations they are
- HQL (Hibernate Query Language)
- Criteria API
- Native SQL
HQL Query Language Features
- Hibernate queries are database independent queries. So that we can develop persistent logic by using HQL
- HQL queries will be written by using pojo class and pojo class member variable
- HQL queries very much similar to sql queries. So learning time of HQL is very less.
- HQL queries are case in-sensitives but pojo class and member variables are case sensitive.
- HQL queries will be converted into SQL queries.
- HQL supports operations, expressions, aggregate functions, sub queries, inner queries and so on..
- HQL queries allows place holders.
- By using HQL we can perform insert, update, delete and select operations. So we can perform DML but we can not perform DDL.
IF you are writing HQL queries we can use the pojo class name instead of table name and we can use pojo class member variables instead of column names.
Example:
SQL:
- Select * from STUDENT( table name);
- select * from STUDENT where FIRSTNAME like ‘r%’;
- select * from STUDENT as sb where sb.hid>100 and sb.hid<200;
- select HID,SFIRSTNAME from STUDENT;
HQL:
- from studentBean(pojo class);
- from studentBean(pojo class) where sfirstname(pojo class variable) like ‘r%’;
- from studentBeansb where sb.hid>100 and sb.hid<200;
- select hid,sfirstname from studentBean
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting, Website Development, and IAM(ForgeRock) Specialist
I am a self-learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.