Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Which interfaces are defined to execute the query in the Hibernate?
The following interfaces are defined to execute the query:
  * Query interface
  * Criteria interface
Both interfaces define several methods for controlling execution of a query.
To create a new Query instance, call either createQuery() or createSQLQuery(). The createQuery() method prepares an HQL query:
  Query q = session.createSQLQuery(
            "select {u.*} from USERS {u}", "u",
            User.class);

To obtain a Criteria instance, call createCriteria(), passing the class of the objects you want the quety to return. This is also called the root entity of the criteria query, the User in this example:
  Criteria c = session.createCriteria(User.class);