One of the nice things about Spring's MVC (SimpleFormController) is the ability to bind data directly to a domain (entity) object's bean properties.
So, going through what happens in handleRequest:
1) In formBackingobject, let us assume we load the entity from a transactionalized service layer.
2) The entity's simple properties are bound automatically.
3) In onBind, we manipulate some of the entity's collections.
If we don't use OpenSessionInView, we'll get a "[net.sf.hibernate.LazyInitializationException] - Failed to lazily initialize a collection - no session or session was closed."
So, for now we'll use OpenSessionInView, with singleSession = false.
4) However, in onSubmit, when we pass this domain object into a transactionalized service-layer "modify" method, we now get an "[net.sf.hibernate.HibernateException] Illegal attempt to associate a collection with two open sessions".
Now, what we really wanted to do here was to enclose the whole request into a transaction, so that the service-layer loading, Spring binding and service-layer persistence all use the same session within the same transaction.
So, my solution is to transactionalize the FormController itself, and specifically it's handleRequest method.
This does away with the need for OpenSessionInView (we can still use it as it was meant of course, for lazy collection access in the View).
It seems to work perfectly well as far as Hibernate is concerned, but is it kosher?