What is Hibernate Query object?
The Hibernate Query object is used to retrieve data from database. You can use either SQL or Hibernate Query
Language (HQL). A Query instance is obtained by calling Session.createQuery().
The Query object is used to bind query parameters, limit query results and execute the query.
Here is the list of Query methods which will be used very often in Hibernate implementations:
list()
Return the query results as a List. If the query contains multiple results pre row, the results are returned
in an instance of Object[].
executeUpdate()
Execute the update or delete statement. It returns the number of entities updated or deleted.
setParameter()
Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is first detected via the
usage/position in the query and if not sufficient secondly guessed from the class of the given object.
uniqueResult()
Convenience method to return a single instance that matches the query, or null if the query returns no results.
setMaxResults()
Set the maximum number of rows to retrieve. If not set, there is no limit to the number of rows retrieved.
setFirstResult()
Set the first row to retrieve. If not set, rows will be retrieved beginning from row 0.
|