While I agree that Spring is really more of an integration framework, it is nevertheless an excellent choice for building a persistence tier. Spring helps to decouple the actual persistence technology, which will help make your application more portable. For instance, if you started building your application using Spring and Hibernate, but later decided to use ibatis, Spring will help to make this migration easier. For instance, Spring provides a generic exception hierarchy that is abstracted from any particular persistence technology, allowing you to handle exceptional conditions, but in a framework-agnostic way.
One of the more alluring features of Spring is its declarative transaction support, allowing you to define transactional rules for your application without having to write lots of boilerplate code. Instead, you can apply annotations to your service layer classes to define the transactional semantics — even to declare granular rules about what exceptions may or may not trigger a rollback.
Additionally, because Spring helps you to keep your code decoupled, it facilitates
testing, and even provides some convenience classes for integration testing.
In my experience, I've found Spring and Hibernate to be an amazing combination, and there's lots of evidence to support this — just look at the new frameworks built on top of Spring and Hibernate, such as grails and roo, among others!
Thanks,
Paul Tepper Fisher, author Spring Persistence with Hibernate