Unfortunately, if you are in a non-web context, you can't use the OpenSessionInView filter or interceptor. As the document listed above points out, you either have to use detached objects, or you have to implement the equivalent of the OpenSessionInView filter yourself.
Joined: Mar 24, 2005
One more note - this is not about transaction demarcation, this problem is about hibernate sessions.
Joined: Mar 22, 2011
I have modified the hibernate tools code templates (ftl files) to generate custom DAOs and Beans.
With the Maven Hibernate Tools Plugin, I generate my database access layer.
Would it be reasonable to add to the Hibenate Beans, a method to reattach a detached object to a new Hibernate session? something like: