|
From: Colin S. <col...@ex...> - 2005-02-19 23:15:49
|
Per Olesen wrote: > Nick Minutello wrote: > >>>> Hence, one web request will quickly >>>> use many connections, at the same time. >>> >> >> >> How so? Why should there be more than one session for a given request? >> > > If the web-layer of the application calls multiple methods into the > services layer where each method performs hibernate work, a new > session will be opened for each hibernate call. That is of course, if > "defferred close" is set on the filter. > > Isn't that how it works? At least, that was what we experienced when > we tried it. Yes, that's exactly how it would work, if you did indeed call down into the tx wrapped service layer multiple times. Of course, it's usually not appropriate to combine data from multiple transactions anyway, but one common case of this is where you call down to get the form backing object contents, and then later call down again with the modified object. The deferred close strategy blows up in this scenario. One workaround which Spring MVC makes pretty easy is to keep your form backing object in the session session, from the previous get. Then you end up only doing one call down into tx layer to apply changes. But this _is_ a limitation, of course. Colin |