Re: T5: Tapestry-Hibernate and thread

2008-01-30 Thread Angelo Chen
this works, thanks. Davor Hrg wrote: > > you inject the ThreadCleanupHub into your service, > > generaly speaking: make sure you dont share DB entities between those > threads since > the new thread will have a completely new hibernate session. > > > Davor Hrg > > > -- View this message

Re: T5: Tapestry-Hibernate and thread

2008-01-30 Thread Davor Hrg
Yes, you can easily create a service that can call your code in a separate thread, and call ThreadCleanupHub.cleanup(); after it. this way any part of your application can use it, and later on you can even use a Thread pool if many such threads are needed. If you create a worker class that execut

Re: T5: Tapestry-Hibernate and thread

2008-01-30 Thread Massimo Lusetti
On Jan 30, 2008 9:18 AM, Davor Hrg <[EMAIL PROTECTED]> wrote: > you inject the ThreadCleanupHub into your service, Better delegating this to another services delegated to serve this pourpose. Regards -- Massimo http://meridio.blogspot.com ---

Re: T5: Tapestry-Hibernate and thread

2008-01-30 Thread Davor Hrg
you inject the ThreadCleanupHub into your service, then you pass it to the new thread either as a parameter, or if the Runnable you run is inner class or annoymous innser class then you just use that... tapestry will give you a same reference for any service, but will redirect method calls to rig

Re: T5: Tapestry-Hibernate and thread

2008-01-29 Thread Angelo Chen
hi, That explains the issue, but how to call ThreadCleanupHub in a thread? Thanks, A.C. Davor Hrg wrote: > > each request is executed inside a thread, > but when you separate your own thread you will get new > resources from tapestry, in your case you will get a new session. > That session wil

Re: T5: Tapestry-Hibernate and thread

2008-01-29 Thread Davor Hrg
each request is executed inside a thread, but when you separate your own thread you will get new resources from tapestry, in your case you will get a new session. That session will not be commited unless you call ThreadCleanupHub after thread exits. Calling ThreadCleanupHub is a must if you use any

Re: T5: Tapestry-Hibernate and thread

2008-01-29 Thread Angelo Chen
found solution, session.flush() at end of the thread, not needed if not in a thread, don't know why. Angelo Chen wrote: > > Hi, > > I have following code in a service: > > Rec p = new Rec(); > session.save(p); > > p.setName("test"); > session.save(p); > > this code works, but if it is invok

T5: Tapestry-Hibernate and thread

2008-01-29 Thread Angelo Chen
Hi, I have following code in a service: Rec p = new Rec(); session.save(p); p.setName("test"); session.save(p); this code works, but if it is invoked in a service under a thread, the change("test") was never saved to the file(the new record is there), any idea? Thanks, A.C. -- View this mes