org.springframework.orm.hibernate4

## Interface HibernateCallback<T>

-     public interface HibernateCallback<T>

  Callback interface for Hibernate code. To be used with `HibernateTemplate`'s execution methods, often as anonymous classes within a method implementation. A typical implementation will call `Session.load/find/update` to perform some operations on persistent objects.
  Since:
    4.0.1
  Author:
    Juergen Hoeller
  See Also:
    `HibernateTemplate`, `HibernateTransactionManager`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `doInHibernate(Session session)` Gets called by `HibernateTemplate.execute` with an active Hibernate `Session`.

- - ### Method Detail

    - #### doInHibernate

          T doInHibernate(Session session)
                   throws HibernateException

      Gets called by `HibernateTemplate.execute` with an active Hibernate `Session`. Does not need to care about activating or closing the `Session`, or handling transactions.

      Allows for returning a result object created within the callback, i.e. a domain object or a collection of domain objects. A thrown custom RuntimeException is treated as an application exception: It gets propagated to the caller of the template.

      Parameters:
        `session` - active Hibernate session
      Returns:
        a result object, or `null` if none
      Throws:
        `HibernateException` - if thrown by the Hibernate API
      See Also:
        `HibernateTemplate.execute(org.springframework.orm.hibernate4.HibernateCallback<T>)`