on on 0 The Spring Framework provides integration with NHibernate in terms of resource management, DAO implementation support, and transaction strategies.

Some of the benefits of using the Spring Framework to create your ORM DAOs include:

  • Ease of testing. Spring's IoC approach makes it easy to swap the implementations and config locations of Hibernate SessionFactory instances, ADO.NET DbProvider instances, transaction managers, and mapper object implementations (if needed).
  • Common data access exceptions.Spring can wrap exceptions from your O/R mapping tool of choice, converting them from proprietary exceptions to a common runtime DataAccessException hierarchy.
  • General resource management. Spring application contexts can handle the location and configuration of Hibernate ISessionFactory instances, ADO.NET DbProvider instances and other related resources.  For example: related code using NHibernate generally needs to use the same NHibernate Session for efficiency and proper transaction handling. Spring makes it easy to transparently create and bind a Session to the current thread
  • Integrated transaction management. Spring allows you to wrap your O/R mapping code with either a declarative, AOP style method interceptor, or an explicit 'template' wrapper class at the code level. In either case, transaction semantics are handled for you, and proper transaction handling (rollback, etc) in case of exceptions is taken care of.
]]>
Provides integration of NHibernate with Spring concepts Classes supporting the Spring.Data.NHibernate namespace