FROM Clause


What is HQL?

HQL stands for Hibernate Query Language. It is the same as SQL language. HQL is an object-oriented language, and it works on objects and their properties instead of tables. HQL uses class names instead of the table name to access data. So HQL is a database-independent query language. HQL is case insensitive language, so there is no barrier of case sensitivity while you write your code.

FROM Clause

FROM clause in HQL is the same as select in SQL. If you want to load a whole object into memory, you can use FROM clause. We can write from EMP, which works the same as selecting * from EMP. We can also make various conditions to retrieve data using ‘FROM clause’ like from EMP as sal etc.

Syntax :

String hql = “FROM Employee”;
Query query = session.createQuery(hql);
List result = query.list();

Advantages of HQL

  • HQL is an independent language, so the program written in HQL can execute in any database without making any changes.
  • HQL supports object-oriented language features like polymorphism, inheritance, etc.
  • Perform all the operations on objects which makes it easy to access data.

Future Scope with HQL

HQL is an object-oriented and independent language. It provides various features like inheritance, polymorphism, and many more. Code reusability is one of the main features of HQL. To learn all these features of HQL, you need to learn HQL properly, which you can learn on any online platform.