|
From: Per O. <po...@no...> - 2005-02-14 15:36:24
|
Hi Juergen, Thank you for your comments. On Monday 14 February 2005 16:13, Juergen Hoeller wrote: > > I am aware of the Hibernate docs that the Session needs to be discarded > when an exception was thrown. However, I find that an overly strict > statement (just like "there is no such thing as a non-transactional > Session", their famous statement from their forums mid last year). Okay, i tend to agree about it being an overly strict statement, also because I've looked into SessionImpl.clear() and it does what we want :-) ... but: When they've explicitly stated that a Session should not be reused in case of exception, upcoming implementations of Session might break spring then. Can it not? > Session.clear should be good enough for resetting an OSIV Session after a > rollback. It's probably advisable to not use OSIV in single session mode at > all if you want to avoid side effects completely. (Closing the Session and > opening a new one during OSIV doesn't really add value here.) It will add the value that: 1) the failing session is thrown away 2) new calls into spring-managed beans will operate fine on the new session I know, that lazy-loading of objects from dead session will fail. > Have you considered using OpenSessionInViewFilter in "deferred close mode", > that is, with the "singleSession" flag turned off? In that case, each > transaction will use its own Hibernate Session, but all of those Sessions > will be kept open until view rendering has completed. Yes, actually I have tried it out. But this solution does not scale very well. A JDBC connection is assigned to each hibernate Session, so using deferred close uses a connection for each session. Hence, one web request will quickly use many connections, at the same time. Per -- Per Olesen @ Nordija A/S - www.nordija.com - main#: +45 70 20 25 10 email: po...@no... - cell#: +45 23 38 95 81 |