spring-framework / org.springframework.orm.hibernate5 / HibernateCallback / doInHibernate

doInHibernate

@Nullable abstract fun doInHibernate(session: Session): T

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

Exceptions

HibernateException - if thrown by the Hibernate API

Return
a result object, or null if none

See Also
HibernateTemplate#execute