As I understand it, using Hibernate/Spring with declarative tx management, there are three options for session management. The first is that each transaction gets its own session which is closed when the transaction block ends.
The second is to use one of the OpenSessionInView classes to bind a Hibernate session to the current thread, and each transaction block uses that thread.
The third (again with OpenSessionInView) is each transaction block gets its own session which is left open after the transaction block ends.
The ideal I would like to get to is yet another option. All methods that get data share a single read only Hibernate session, and all write methods get their own Hibernate session which is committed and closed when the tx ends.
All transactional methods will receive data (could be hibernate objects tied to a session or just copies of data from request params), with their own Hib session they will load hib objects and copy data from input to those objects and commit transaction. In this way you have total control over what is saved and you can see it all explicitly in a single transactional method.
I am currently trying to get this to work with Hibernate 3.0.5 and Spring 1.2.2. Any ideas or help would be appreciated.