Interface that specifies a basic set of Hibernate operations, implemented by {@link HibernateTemplate}. Not often used, but a useful option to enhance testability, as it can easily be mocked or stubbed.
Defines HibernateTemplate
's data access methods that mirror various {@link org.hibernate.Session} methods. Users arestrongly encouraged to read the Hibernate Session
javadocs for details on the semantics of those methods.
Note that operations that return an {@link java.util.Iterator} (i.e.iterate(..)
) are supposed to be used within Spring-driven or JTA-driven transactions (with {@link HibernateTransactionManager}, {@link org.springframework.transaction.jta.JtaTransactionManager}, or EJB CMT). Else, the Iterator
won't be able to read results from its {@link java.sql.ResultSet} anymore, as the underlyingHibernate Session
will already have been closed.
Note that lazy loading will just work with an open Hibernate Session
, either within a transaction or within {@link org.springframework.orm.hibernate3.support.OpenSessionInViewFilter}/ {@link org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor}. Furthermore, some operations just make sense within transactions, for example: contains
, evict
, lock
, flush
, clear
.
@author Juergen Hoeller
@since 1.2
@see HibernateTemplate
@see org.hibernate.Session
@see HibernateTransactionManager
@see org.springframework.transaction.jta.JtaTransactionManager
@see org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
@see org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor