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
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
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:
- public int executeUpdate() is used to
execute the update or delete query.
- public List list() returns the result
of the ralation as a list.
- public Query setFirstResult(int rowno)
specifies the row number from where record will be retrieved.
- public Query setMaxResult(int rowno)
specifies the no. of records to be retrieved from the relation
- public Query setParameter(int position,
Object value) it sets the value to the JDBC style query
- public Query setParameter(String name,
Object value) it sets the value to a named query parameter.