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 right instance.
at the end of the new Thread's work, call cleanup()... and tapestry
will clear the resources
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
On Jan 30, 2008 2:16 AM, Angelo Chen <[EMAIL PROTECTED]> wrote:
>
> 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 will not be commited unless you call ThreadCleanupHub
> > after thread exits.
> > Calling ThreadCleanupHub is a must if you use any threaded resources
> > from tapestry,
> > otherwise expect strange behavior and memory leaks.
> >
> > Davor Hrg
> >
> >
> >
> >
> > On Jan 29, 2008 11:20 AM, Angelo Chen <[EMAIL PROTECTED]> wrote:
> >>
> >> 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 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 message in context:
> >> http://www.nabble.com/T5%3A-Tapestry-Hibernate-and-thread-tp15155391p15156420.html
> >>
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Tapestry-Hibernate-and-thread-tp15155391p15173609.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]