you should call ThreadCleanupHub.cleanup() at the
each thread you spawn for your self, or tapestry threaded
resources will not get cleaned, and youl make a mem leak.


tapestry uses ThreadLocal to store threaded services like Session,
for example if any part of the code references session(calls a method)
while it is
executed from your thread new session for that thread will be created,
and without calling ThreadCleanupHub.cleanup() inside that thread service




On Feb 7, 2008 9:41 AM, Angelo Chen <[EMAIL PROTECTED]> wrote:
>
> Hi Andy,
>
> Thanks for the quick reply, based on that I modified it as follow:
>
>    @Inject
>    private HibernateSessionManager sessionManager;
>
>     Object onSuccess() {
>          final Long id = create.append();
>         sessionManager.commit();
>         new Thread(new Runnable() {
>             public void run() {
>               myThread.findMe(id);
>             }
>
>         }).start();
>
>
>         return null;
>     }
>
> It seems working.
>
> A.c.
>
>
> Andy Huhn wrote:
> >
> > Hi Angelo,
> >
> > The MyCreate service creates a new record, but doesn't commit until
> > after MyThread is started.
> >
> > The MyThread service automatically gets a different Hibernate Session,
> > and thus can't see the record that hasn't been committed yet by the
> > other session.
> >
> > I'm not that familiar with MySQL, but my guess is that the InnoDB engine
> > supports transactions, while the MyISAM engine doesn't?
> >
> > If you want this record to be visible across two different threads, you
> > must commit before you start the second thread.  Or perhaps it's simpler
> > not to use a second thread, and do everything in one session.
> >
> > Andy
> >
> > On Wed, 2008-02-06 at 22:33 -0800, Angelo Chen wrote:
> >> Hi,
> >>
> >> I have two services, namely MyCreate and MyThread, what they do is:
> >>
> >
>
> --
> View this message in context: 
> http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15329490.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]

Reply via email to