Where Clause


What are Clauses?

Clauses are keywords created or defined to perform some work on data. HQL is an object-oriented language, so every operation is performed on an object. If you want to load the whole object in memory, you can use from clause. HQL is not case sensitive language, so that you can write clauses either in capital or in small format.

Where Clause

Clauses are keywords created or defined to perform some work on data. HQL is an object-oriented language, so every operation is performed on an object. If you want to load the whole object in memory, you can use from clause. HQL is not case sensitive language, so that you can write clauses either in capital or in small format.

Syntax :

String hql = “FROM Emp e where e.id = 10”;
Query query = session.createQuery(hql);
List result = query.list();

Difference between HQL and SQL

  • SQL is based on a relational model, while HQL is based on an Object-Oriented model.
  • SQL stores data in tables and modifies the rows and columns, where HQL stores object to store data.
  • SQL considers relationships among two tables, whereas HQL considers relations among two objects.
  • SQL offers a complex interface where the HQL user interface is user-friendly.
  • SQL is a case-sensitive language, whereas HQL is not case-sensitive.

Future Scope of HQL

HQL is an advanced language than SQL, and it uses JAVA language classes and variables to store and access data. This feature makes HQL more popular. Many of the companies are hiring developers who know HQL well. To learn HQL properly, there are various online platforms to understand it.