View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12829 Members
Join this group to post and comment.
K!r@nS!ngu
K!r@nS!ngu • Mar 18, 2012

HQL - How it is different from SQL ?

The Hibernate Query Language


What are the main differences between HQL and SQL ?
HQL is getting information based on POJOs(classes) and its variables,where as SQL is getting information based on tabels and their columns
Eg:in hibernate you have Student(studentId,studentName(varibles)) class these class information stored in student(sid,sname(column names)) table.if you want to get total students information from table where student name contains na has substring

SQL select * from student where sname like '%na%';
HQL select * from Student s where s.studentName like '%na%';

Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties. HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action on database.

Few differences between SQL and HQL.

  • SQL is based on relational database model whereas HQL is a combination of OOPS with Relational database concept.
  • SQL manipulates data stored in tables and modifies its rows and columns while HQL is concerned about objects and its properties.
  • SQL is concerned about the relationship that exists between two tables while HQL is concerned about relation between objects.

Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties. HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action on database.

Few differences between SQL and HQL.

  • SQL is based on relational database model whereas HQL is a combination of OOPS with Relational database concept.
  • SQL manipulates data stored in tables and modifies its rows and columns while HQL is concerned about objects and its properties.
  • SQL is concerned about the relationship that exists between two tables while HQL is concerned about relation between objects.

Share this content on your social channels -