Step To Execute HQL queries Using Hibernate
Previous Home Next

The following three steps are required in executeing HQL queries.

  1. Obtaining an instance of org.hibernate.Query
  2. Customize the Query object
  3. Execute the Query
Obtaining an instance of org.hibernate.Query

A Query instance is obtained by calling Session.createQuery() or Session.getNamedQuery method. The createQuery() method is used to create a new instance of Query for given HQL Query.

Customize the Query object

After obtaining the query object we may want to customize it by setting query parameter,cache mode, Flush mode,fetch size ,an upper limit for the result set.

Execute the Query

After preparing the query object by setting all custom properties we use list(),scroll(),iterate() or uniqueResult().

Previous Home Next