emmanuel wrote:
the Spring Framework is an example of separation pattern while intensive ORM capabilities usage. Juergen will probably detail that ;-)
I'm a bit late here, but good point, of course ;-)
Spring provides generic transaction management combined with generic DAO support. You can demarcate your transactions in a generic way in your business facades, without being tied to any particular data access tool. The actual transaction strategy is configurable: for Hibernate, HibernateTransactionManager or JtaTransactionManager would be appropriate.
If your DAOs are coded with Hibernate, the Hibernate Session will automatically get bound to the transaction. So if you rely on lazy loading, you can do that as long as the transaction is active - without dependencies on Hibernate in that transactional business code! On transaction commit, the Session will automatically be closed by Spring's transaction manager.
While Spring provides all of these services for POJOs, either programmatically or declaratively via AOP, it can also be used within EJBs. You simply need to demarcate a transaction with JtaTransactionManager as strategy there, in addition to EJB's CMT: This will automatically participate in the existing JTA transaction, but additionally bind resources like a Hibernate Session for the course of the sub-transaction.
Juergen
http://www.springframework.org
http://www.hibernate.org/110.html