You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/03/11 04:16:58 UTC

T5: getting new Hibernate session in a lengthy thread

Hi,

I need to run a lengthy thread where some database update happens, is there
a way to minimize the time when a Hibernate Session is used? something
similar to:

do while not done

	// do some processing here
	obtain a session
	use the session
	release the session

enddo

If I use HibernateSessionManager, it seems there is no way to release and
obtain a new session, any idea?
-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: getting new Hibernate session in a lengthy thread

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,

The process is in a separate thread, wrapped in a service, and Session is
injected into the service, the process takes quite a long time, I have to
restart tomcat service almost everyday.

Now, instead of injecting Session, I injected the HibernateSessionSource,
then I can control the session/transaction as a normal hibernate
application, it works very well. I'd say, HibernateSessionSource is a very
good service.

Angelo


Lutz Hühnken wrote:
> 
> Hi Angelo,
> 
> I think the point of sticking the session to the request is to keep it
> open until the request is processed, to avoid
> LazyInitializationExceptions during view rendering. So you might have
> to do your session management without the HibernateSessionManager.
> 
> Then again, I wonder if it really makes much of a difference - if the
> database stuff is done in the request processing thread, what do you
> achieve by closing the session a tiny bit earlier than it would be by
> the HibernateSessionManager anyway?
> 
> If the database update is really so lengthy, you might want to do it
> in a separate thread altogether.
> 
> Hth,
> 
> Lutz
> 
> 
> On Wed, Mar 11, 2009 at 4:16 AM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
>>
>> Hi,
>>
>> I need to run a lengthy thread where some database update happens, is
>> there
>> a way to minimize the time when a Hibernate Session is used? something
>> similar to:
>>
>> do while not done
>>
>>        // do some processing here
>>        obtain a session
>>        use the session
>>        release the session
>>
>> enddo
>>
>> If I use HibernateSessionManager, it seems there is no way to release and
>> obtain a new session, any idea?
>> --
>> View this message in context:
>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> altocon GmbH
> http://www.altocon.de/
> Software Development, Consulting
> Hamburg, Germany
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22524691.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: getting new Hibernate session in a lengthy thread

Posted by Lutz Hühnken <lh...@googlemail.com>.
Hi Angelo,

I think the point of sticking the session to the request is to keep it
open until the request is processed, to avoid
LazyInitializationExceptions during view rendering. So you might have
to do your session management without the HibernateSessionManager.

Then again, I wonder if it really makes much of a difference - if the
database stuff is done in the request processing thread, what do you
achieve by closing the session a tiny bit earlier than it would be by
the HibernateSessionManager anyway?

If the database update is really so lengthy, you might want to do it
in a separate thread altogether.

Hth,

Lutz


On Wed, Mar 11, 2009 at 4:16 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> I need to run a lengthy thread where some database update happens, is there
> a way to minimize the time when a Hibernate Session is used? something
> similar to:
>
> do while not done
>
>        // do some processing here
>        obtain a session
>        use the session
>        release the session
>
> enddo
>
> If I use HibernateSessionManager, it seems there is no way to release and
> obtain a new session, any idea?
> --
> View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by DH <ni...@gmail.com>.
Hi,

Yes, I think so. HibernateSessionSource is top of HibernateSessionManager.


DH


----- Original Message ----- 
From: "Angelo Chen" 
To: <us...@tapestry.apache.org>
Sent: Wednesday, March 11, 2009 2:08 PM
Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread



Hi,

HibernateSessionManagerImpl uses HibernateSessionSource to create a session,
if we use HibernateSessionSource service in code as suggested by you, then
seems ok, right?



dh ning wrote:
> 
> Sorry, my fault. If code don't call any method of HibernateSessionManager,
> it won't create a session.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" 
> To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 1:55 PM
> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
> 
> that will be a thread trigger by Quartz, create the session, close the
> session repeat this until thread is over, i don't know any impact from
> Tapestry-Hibernate.
> 
> 
> dh ning wrote:
>> 
>> I haven't tried it yet because now my application is out of
>> tapestry-hibernate.
>> But from source code of tapestry-hibernate, it should be doable.
>> 
>> But I still doubt how you close the session created by
>> HibernateSessionManager (thread scope). 
>> If you don't close it manually, the session still last fro the whole
>> request process.
>> If close manually, maybe 'session has closed' exception is thrown by
>> tapestry-hibernate because at the end tapestry would try to close the
>> session of HibernateSessionManager, but it has been closed manually.
>> 
>> Thanks,
>> DH
>> 
>> 
>> ----- Original Message ----- 
>> From: "Angelo Chen" To: <us...@tapestry.apache.org>
>> Sent: Wednesday, March 11, 2009 1:17 PM
>> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
>> 
>> 
>> 
>> Hi DH,
>> 
>> That sounds doable, we will inject the HibernateSessionSource then call
>> create() to obtain the session?
>> 
>> Angelo
>> 
>> 
>> dh ning wrote:
>>> 
>>> Maybe you can directly use HibernateSessionSource service instead of
>>> HibernateSessionManager.
>>> HibernateSessionSource.create() creates a new session always, and do
>>> remember to commit and close the session by yourself.
>>> 
>>> Thanks,
>>> DH
>>> 
>>> 
>>> ----- Original Message ----- 
>>> From: "Angelo Chen" <an...@yahoo.com.hk>
>>> To: <us...@tapestry.apache.org>
>>> Sent: Wednesday, March 11, 2009 11:16 AM
>>> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
>>> 
>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> I need to run a lengthy thread where some database update happens, is
>>>> there
>>>> a way to minimize the time when a Hibernate Session is used? something
>>>> similar to:
>>>> 
>>>> do while not done
>>>> 
>>>> // do some processing here
>>>> obtain a session
>>>> use the session
>>>> release the session
>>>> 
>>>> enddo
>>>> 
>>>> If I use HibernateSessionManager, it seems there is no way to release
>>>> and
>>>> obtain a new session, any idea?
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>> 
>>>>
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449240.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449328.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,

HibernateSessionManagerImpl uses HibernateSessionSource to create a session,
if we use HibernateSessionSource service in code as suggested by you, then
seems ok, right?



dh ning wrote:
> 
> Sorry, my fault. If code don't call any method of HibernateSessionManager,
> it won't create a session.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" 
> To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 1:55 PM
> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
> 
> that will be a thread trigger by Quartz, create the session, close the
> session repeat this until thread is over, i don't know any impact from
> Tapestry-Hibernate.
> 
> 
> dh ning wrote:
>> 
>> I haven't tried it yet because now my application is out of
>> tapestry-hibernate.
>> But from source code of tapestry-hibernate, it should be doable.
>> 
>> But I still doubt how you close the session created by
>> HibernateSessionManager (thread scope). 
>> If you don't close it manually, the session still last fro the whole
>> request process.
>> If close manually, maybe 'session has closed' exception is thrown by
>> tapestry-hibernate because at the end tapestry would try to close the
>> session of HibernateSessionManager, but it has been closed manually.
>> 
>> Thanks,
>> DH
>> 
>> 
>> ----- Original Message ----- 
>> From: "Angelo Chen" To: <us...@tapestry.apache.org>
>> Sent: Wednesday, March 11, 2009 1:17 PM
>> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
>> 
>> 
>> 
>> Hi DH,
>> 
>> That sounds doable, we will inject the HibernateSessionSource then call
>> create() to obtain the session?
>> 
>> Angelo
>> 
>> 
>> dh ning wrote:
>>> 
>>> Maybe you can directly use HibernateSessionSource service instead of
>>> HibernateSessionManager.
>>> HibernateSessionSource.create() creates a new session always, and do
>>> remember to commit and close the session by yourself.
>>> 
>>> Thanks,
>>> DH
>>> 
>>> 
>>> ----- Original Message ----- 
>>> From: "Angelo Chen" <an...@yahoo.com.hk>
>>> To: <us...@tapestry.apache.org>
>>> Sent: Wednesday, March 11, 2009 11:16 AM
>>> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
>>> 
>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> I need to run a lengthy thread where some database update happens, is
>>>> there
>>>> a way to minimize the time when a Hibernate Session is used? something
>>>> similar to:
>>>> 
>>>> do while not done
>>>> 
>>>> // do some processing here
>>>> obtain a session
>>>> use the session
>>>> release the session
>>>> 
>>>> enddo
>>>> 
>>>> If I use HibernateSessionManager, it seems there is no way to release
>>>> and
>>>> obtain a new session, any idea?
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>> 
>>>>
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449240.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449328.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by DH <ni...@gmail.com>.
Sorry, my fault. If code don't call any method of HibernateSessionManager, it won't create a session.

Thanks,
DH


----- Original Message ----- 
From: "Angelo Chen" 
To: <us...@tapestry.apache.org>
Sent: Wednesday, March 11, 2009 1:55 PM
Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread



that will be a thread trigger by Quartz, create the session, close the
session repeat this until thread is over, i don't know any impact from
Tapestry-Hibernate.


dh ning wrote:
> 
> I haven't tried it yet because now my application is out of
> tapestry-hibernate.
> But from source code of tapestry-hibernate, it should be doable.
> 
> But I still doubt how you close the session created by
> HibernateSessionManager (thread scope). 
> If you don't close it manually, the session still last fro the whole
> request process.
> If close manually, maybe 'session has closed' exception is thrown by
> tapestry-hibernate because at the end tapestry would try to close the
> session of HibernateSessionManager, but it has been closed manually.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 1:17 PM
> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
> 
> Hi DH,
> 
> That sounds doable, we will inject the HibernateSessionSource then call
> create() to obtain the session?
> 
> Angelo
> 
> 
> dh ning wrote:
>> 
>> Maybe you can directly use HibernateSessionSource service instead of
>> HibernateSessionManager.
>> HibernateSessionSource.create() creates a new session always, and do
>> remember to commit and close the session by yourself.
>> 
>> Thanks,
>> DH
>> 
>> 
>> ----- Original Message ----- 
>> From: "Angelo Chen" <an...@yahoo.com.hk>
>> To: <us...@tapestry.apache.org>
>> Sent: Wednesday, March 11, 2009 11:16 AM
>> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
>> 
>> 
>>> 
>>> Hi,
>>> 
>>> I need to run a lengthy thread where some database update happens, is
>>> there
>>> a way to minimize the time when a Hibernate Session is used? something
>>> similar to:
>>> 
>>> do while not done
>>> 
>>> // do some processing here
>>> obtain a session
>>> use the session
>>> release the session
>>> 
>>> enddo
>>> 
>>> If I use HibernateSessionManager, it seems there is no way to release
>>> and
>>> obtain a new session, any idea?
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>>>
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449240.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by Angelo Chen <an...@yahoo.com.hk>.
that will be a thread trigger by Quartz, create the session, close the
session repeat this until thread is over, i don't know any impact from
Tapestry-Hibernate.


dh ning wrote:
> 
> I haven't tried it yet because now my application is out of
> tapestry-hibernate.
> But from source code of tapestry-hibernate, it should be doable.
> 
> But I still doubt how you close the session created by
> HibernateSessionManager (thread scope). 
> If you don't close it manually, the session still last fro the whole
> request process.
> If close manually, maybe 'session has closed' exception is thrown by
> tapestry-hibernate because at the end tapestry would try to close the
> session of HibernateSessionManager, but it has been closed manually.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 1:17 PM
> Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
> 
> Hi DH,
> 
> That sounds doable, we will inject the HibernateSessionSource then call
> create() to obtain the session?
> 
> Angelo
> 
> 
> dh ning wrote:
>> 
>> Maybe you can directly use HibernateSessionSource service instead of
>> HibernateSessionManager.
>> HibernateSessionSource.create() creates a new session always, and do
>> remember to commit and close the session by yourself.
>> 
>> Thanks,
>> DH
>> 
>> 
>> ----- Original Message ----- 
>> From: "Angelo Chen" <an...@yahoo.com.hk>
>> To: <us...@tapestry.apache.org>
>> Sent: Wednesday, March 11, 2009 11:16 AM
>> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
>> 
>> 
>>> 
>>> Hi,
>>> 
>>> I need to run a lengthy thread where some database update happens, is
>>> there
>>> a way to minimize the time when a Hibernate Session is used? something
>>> similar to:
>>> 
>>> do while not done
>>> 
>>> // do some processing here
>>> obtain a session
>>> use the session
>>> release the session
>>> 
>>> enddo
>>> 
>>> If I use HibernateSessionManager, it seems there is no way to release
>>> and
>>> obtain a new session, any idea?
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>>>
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22449240.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by DH <ni...@gmail.com>.
I haven't tried it yet because now my application is out of tapestry-hibernate.
But from source code of tapestry-hibernate, it should be doable.

But I still doubt how you close the session created by HibernateSessionManager (thread scope). 
If you don't close it manually, the session still last fro the whole request process.
If close manually, maybe 'session has closed' exception is thrown by tapestry-hibernate because at the end tapestry would try to close the session of HibernateSessionManager, but it has been closed manually.

Thanks,
DH


----- Original Message ----- 
From: "Angelo Chen" To: <us...@tapestry.apache.org>
Sent: Wednesday, March 11, 2009 1:17 PM
Subject: Re: T5ï¼s getting new Hibernate session in a lengthy thread



Hi DH,

That sounds doable, we will inject the HibernateSessionSource then call
create() to obtain the session?

Angelo


dh ning wrote:
> 
> Maybe you can directly use HibernateSessionSource service instead of
> HibernateSessionManager.
> HibernateSessionSource.create() creates a new session always, and do
> remember to commit and close the session by yourself.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" <an...@yahoo.com.hk>
> To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 11:16 AM
> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
>> 
>> Hi,
>> 
>> I need to run a lengthy thread where some database update happens, is
>> there
>> a way to minimize the time when a Hibernate Session is used? something
>> similar to:
>> 
>> do while not done
>> 
>> // do some processing here
>> obtain a session
>> use the session
>> release the session
>> 
>> enddo
>> 
>> If I use HibernateSessionManager, it seems there is no way to release and
>> obtain a new session, any idea?
>> -- 
>> View this message in context:
>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>>
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi DH,

That sounds doable, we will inject the HibernateSessionSource then call
create() to obtain the session?

Angelo


dh ning wrote:
> 
> Maybe you can directly use HibernateSessionSource service instead of
> HibernateSessionManager.
> HibernateSessionSource.create() creates a new session always, and do
> remember to commit and close the session by yourself.
> 
> Thanks,
> DH
> 
> 
> ----- Original Message ----- 
> From: "Angelo Chen" <an...@yahoo.com.hk>
> To: <us...@tapestry.apache.org>
> Sent: Wednesday, March 11, 2009 11:16 AM
> Subject: T5ï¼s getting new Hibernate session in a lengthy thread
> 
> 
>> 
>> Hi,
>> 
>> I need to run a lengthy thread where some database update happens, is
>> there
>> a way to minimize the time when a Hibernate Session is used? something
>> similar to:
>> 
>> do while not done
>> 
>> // do some processing here
>> obtain a session
>> use the session
>> release the session
>> 
>> enddo
>> 
>> If I use HibernateSessionManager, it seems there is no way to release and
>> obtain a new session, any idea?
>> -- 
>> View this message in context:
>> http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>>
> 

-- 
View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448992.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5ï¼s getting new Hibernate session in a lengthy thread

Posted by DH <ni...@gmail.com>.
Maybe you can directly use HibernateSessionSource service instead of HibernateSessionManager.
HibernateSessionSource.create() creates a new session always, and do remember to commit and close the session by yourself.

Thanks,
DH


----- Original Message ----- 
From: "Angelo Chen" <an...@yahoo.com.hk>
To: <us...@tapestry.apache.org>
Sent: Wednesday, March 11, 2009 11:16 AM
Subject: T5ï¼s getting new Hibernate session in a lengthy thread


> 
> Hi,
> 
> I need to run a lengthy thread where some database update happens, is there
> a way to minimize the time when a Hibernate Session is used? something
> similar to:
> 
> do while not done
> 
> // do some processing here
> obtain a session
> use the session
> release the session
> 
> enddo
> 
> If I use HibernateSessionManager, it seems there is no way to release and
> obtain a new session, any idea?
> -- 
> View this message in context: http://www.nabble.com/T5%EF%BC%9A-getting-new-Hibernate-session-in-a-lengthy-thread-tp22448134p22448134.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>