Hibernate Query Language (HQL)

In this page you can learn Sleep Query Language (HQL) is same as SQL (Structured Query Language) yet it doesn't relies on upon the table of the database. Rather than table name, we utilize class name in HQL. So it is database free inquiry dialect.

Favorable position of HQL

There are numerous favorable circumstances of HQL. They are as per the following:

  • database independent
  • supports polymorphic queries
  • easy to learn for Java Programmer

Query Interface

It is an object oriented representation of Hibernate Query. The object of Query can be obtained by calling the createQuery() method Session interface.

The query interface provides many methods. There is given commonly used methods:

  1. public int executeUpdate() is used to execute the update or delete query.
  2. public List list() returns the result of the ralation as a list.
  3. public Query setFirstResult(int rowno) specifies the row number from where record will be retrieved.
  4. public Query setMaxResult(int rowno) specifies the no. of records to be retrieved from the relation (table).
  5. public Query setParameter(int position, Object value) it sets the value to the JDBC style query parameter.
  6. public Query setParameter(String name, Object value) it sets the value to a named query parameter.