You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michal Hlavac <hl...@hlavki.sk> on 2005/09/19 14:43:48 UTC
Close Hibernate session on every request
Hello,
I am using tapestry 4. I created UniwebBasePage extends BasePage
there is method:
protected Session session = null;
public Session getSession() {
if (session == null) {
session = getHibernateGlobal().openSession();
System.out.println("zakladam session");
return session;
} else {
return session;
}
}
when I call from other pages, for example
LoginPage extends UniwebBasePage
public void test() {
Session sess = getSession();
Query q = ...
}
everything is ok, but I want to close session after every request.
Two questions:
1. Is this good performace step ( close hibernate session on every
request)??? If no, is there some any solutions?
2. if yes, how can I do that??
thanks, miso
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Close Hibernate session on every request
Posted by Paul Cantrell <ca...@pobox.com>.
This should be fine for performance, unless your site has an
extremely high load.
You can use a servlet filter to do this.
Cheers,
Paul
On Sep 19, 2005, at 7:43 AM, Michal Hlavac wrote:
> Hello,
>
> I am using tapestry 4. I created UniwebBasePage extends BasePage
>
> there is method:
>
> protected Session session = null;
>
> public Session getSession() {
> if (session == null) {
> session = getHibernateGlobal().openSession();
> System.out.println("zakladam session");
> return session;
> } else {
> return session;
> }
> }
>
> when I call from other pages, for example
> LoginPage extends UniwebBasePage
>
> public void test() {
> Session sess = getSession();
> Query q = ...
> }
>
> everything is ok, but I want to close session after every request.
> Two questions:
>
> 1. Is this good performace step ( close hibernate session on every
> request)??? If no, is there some any solutions?
>
> 2. if yes, how can I do that??
>
> thanks, miso
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Close Hibernate session on every request
Posted by Kent Tong <ke...@cpttm.org.mo>.
Michal Hlavac <hlavki <at> hlavki.sk> writes:
>
> Aleksej wrote:
>
> > You shold use hivemind ( which is integrated into T4 ) threaded service
> > to create a Hibernate session for you.
>
> ok...
> is there some example??
There is an example at
http://www.theserverside.com/articles/article.tss?l=HivemindBuzz. There
is a whole chapter dedicated to this topic (Hibernate in Tapestry 4)
in my book.
--
Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Close Hibernate session on every request
Posted by Massimo Lusetti <ml...@gmail.com>.
On 9/19/05, Michal Hlavac <hl...@hlavki.sk> wrote:
> ok...
> is there some example??
Maybe this read could give you hints:
http://jakarta.apache.org/tapestry/UsersGuide/hivemind.html
--
Massimo
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Close Hibernate session on every request
Posted by Michal Hlavac <hl...@hlavki.sk>.
Aleksej wrote:
> You shold use hivemind ( which is integrated into T4 ) threaded service
> to create a Hibernate session for you.
ok...
is there some example??
thanks, miso
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Close Hibernate session on every request
Posted by Aleksej <al...@ivs.lt>.
Michal Hlavac wrote:
>Hello,
>
>I am using tapestry 4. I created UniwebBasePage extends BasePage
>
>there is method:
>
> protected Session session = null;
>
> public Session getSession() {
> if (session == null) {
> session = getHibernateGlobal().openSession();
> System.out.println("zakladam session");
> return session;
> } else {
> return session;
> }
> }
>
>when I call from other pages, for example
>LoginPage extends UniwebBasePage
>
>public void test() {
> Session sess = getSession();
> Query q = ...
>}
>
>everything is ok, but I want to close session after every request.
>Two questions:
>
>1. Is this good performace step ( close hibernate session on every
>request)??? If no, is there some any solutions?
>
>2. if yes, how can I do that??
>
>thanks, miso
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
>
You shold use hivemind ( which is integrated into T4 ) threaded service
to create a Hibernate session for you.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org