|
From: Colin S. <col...@ex...> - 2004-08-20 21:54:04
|
If you use the new mode of the OpenSessionInViewFilter where there are
multiple sessions, but close is deferred, then in fact there is no
existing session yet.
If you use the old mode, with just one session, then it's probably not
the end of the world. The tx sync ensures a flush, and also a callback
into Hibernate's SessionImplementor.afterTransactionCompletion()
callback method. With the default flushmode setting, adding back in the
HibernateInterceptor to force a flush would not do it, since it would
find the session already on the thread and would not flush on coming
back, on that basis. You could force a flush with a FLUSH_EAGER setting,
but then if you had multiple wrapped invocaitons, you'd flush on coming
back from every one, not just the outer.
I may be missing something; Juergen feel free to comment if the above is
not accurate.
Regards,
Colin
March, Andres wrote:
>How does this apply to OpenSessionInViewFilter though? The session is
>always opened before a transaction begins.
>
>
>
>>-----Original Message-----
>>From: spr...@li...
>>[mailto:spr...@li...] On
>>
>>
>Behalf
>
>
>>Of Colin Sampaleanu
>>Sent: Friday, August 20, 2004 11:11 AM
>>To: spr...@li...
>>Subject: [Springframework-developer] HibernateInterceptor
>>
>>Juergen,
>>
>>If the HibernateInterceptor is currently applied before the
>>TransactionInterceptor instead of after it, the invoke method still
>>ensures the SessionHolder is bound to the thread, but no
>>
>>
>synchronization
>
>
>>can be registered of course. In this case, all you get is a logged
>> logger.debug("Using new session for Hibernate
>>
>>
>interceptor");
>
>
>>Do you think it's perhaps worth being a bit more explicit and
>>
>>
>mentioning
>
>
>>that no transaction currently exists? Most of the time, unless
>>
>>
>somebody
>
>
>>really wants to use HibernateInterceptor to create sessions outside of
>>
>>
>a
>
>
>>transaction, this will be a config error, and people would be better
>>
>>
>of
>
>
>>changing the ordering so that the session is created after the
>>transaction, and can be synchronized...
>>
>>Colin
>>
>>
>>
>>
>>
>>-------------------------------------------------------
>>SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
>>100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
>>Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
>>http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
>>_______________________________________________
>>Springframework-developer mailing list
>>Spr...@li...
>>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>>
>>
|