The answer is no, you can not make session threadsafe when a user submits 
twice, there will be two threads accesing the same hibernate session, wich 
is not threadsafe.
But you can avoid users submitting twice, using Synchronizer Token Pattern (
http://www.javaworld.com/javaworld/javatips/jw-javatip136.html).

On 8/7/05, Lukáš Kolísko <[EMAIL PROTECTED]> wrote:
> 
> Hello,
> maybe this is a newbie question, but is there a possible pattern how
> to implement long term session in Tapestry application in thread safe
> way.
> 
> I am using tapestry ver. 3.0.3. I open session using ThreadLocal
> object from a static method when it is needed (The pattern show in
> Hibernate in Action book) and I close session using detach method of
> each page. This pattern works good for me, but when I want to use some
> object across many pages this pattern of course does not work with
> lazy initialization. I have to reconnect object to hibernate session
> or load a part of object tree into memory with lazy=false attributes (
> but this is very memory consuming )
> 
> I am not sure if it is possible to use setupForRequest and
> cleanupAfterRequest methods to store hibernate session to user session
> and restore it after next request comes and connect it back to jdbc. I
> think this is not thread safe when user for example clicks more times
> submit button before the first request is completed. In this case more
> same hibernate session object would be taken from user session but
> after each request end the persistent session will be overwritten in
> non consistent way and hibernate session object is not thread safe
> itself.
> 
> I would be very grateful for any suggestion or response.
> I solve this problem in my dissertation application.
> 
> Sorry for my english.
> 
> Lukas Kolisko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

Reply via email to