0 votes
in JAVA by
What is HQL and What are its Benefits?

1 Answer

0 votes
by

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 turn perform an action on a database. Although you can use SQL statements directly with Hibernate using Native SQL, I would recommend using HQL whenever possible to avoid database portability hassles and to take advantage of Hibernate's SQL generation and caching strategies.

Hibernate query language is case-insensitive except for java class and variable names.

The HQL queries are cached but we should avoid it as much as possible, otherwise, we will have to take care of associations. However, it’s a better choice than a native SQL query because of the Object-Oriented approach.

...