You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sohail Aslam <so...@techlogix.com> on 2003/09/27 08:47:25 UTC

Hibernate initialization

I am attempting to use hibernate in a tapestry-based application. I 
would like to carry out hibernate related initialization *before* the 
very first html (home) page appears, i.e., I want the following to 
happen before the the user sees the first page of the application.

            Configuration cfg = new Configuration();
             cfg.addClass(com.cgc.esd.pages.csys.User.class)
                .addClass(com.cgc.esd.pages.csys.Application.class)
                .addClass(com.cgc.esd.pages.csys.Actor.class)
                .addClass(com.cgc.esd.pages.csys.Usecase.class)
                .addClass(com.cgc.esd.pages.csys.Role.class)
                .addClass(com.cgc.esd.pages.csys.Responsibility.class)
                .addClass(com.cgc.esd.pages.cinv.Buyer.class)
                .addClass(com.cgc.esd.pages.cinv.BuyerCompositeID.class)
                ;
             Properties properties=new Properties();
             properties.load(HUtil.class.
                getResourceAsStream("/hibernate.properties"));
             cfg.setProperties(properties);
             sessionFactory=cfg.buildSessionFactory();

The first page is the login page. Right now, the initialization happens 
in the visit.authenicate() method that the login page's listener method 
invokes to validate a user's credentials using the user's profile stored 
in a db table. If the login is successful, the user sees the "main" 
page. The problem is that there is a delay in the login and the 
appearence of the main page because of all the hibernate initialization 
happening the very first time. This needs to be done only once. Is there 
an engine method akin to servlet's init method where I can do such one 
time initialization? What is a good place to do this?

Thanks
Sohail Aslam
Techlogix Inc.
www.techlogix.com



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


Re: Hibernate initialization

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Put the initializations in the Global's constructor.

-Harish

Sohail Aslam wrote:

> I am attempting to use hibernate in a tapestry-based application. I 
> would like to carry out hibernate related initialization *before* the 
> very first html (home) page appears, i.e., I want the following to 
> happen before the the user sees the first page of the application.
>
>            Configuration cfg = new Configuration();
>             cfg.addClass(com.cgc.esd.pages.csys.User.class)
>                .addClass(com.cgc.esd.pages.csys.Application.class)
>                .addClass(com.cgc.esd.pages.csys.Actor.class)
>                .addClass(com.cgc.esd.pages.csys.Usecase.class)
>                .addClass(com.cgc.esd.pages.csys.Role.class)
>                .addClass(com.cgc.esd.pages.csys.Responsibility.class)
>                .addClass(com.cgc.esd.pages.cinv.Buyer.class)
>                .addClass(com.cgc.esd.pages.cinv.BuyerCompositeID.class)
>                ;
>             Properties properties=new Properties();
>             properties.load(HUtil.class.
>                getResourceAsStream("/hibernate.properties"));
>             cfg.setProperties(properties);
>             sessionFactory=cfg.buildSessionFactory();
>
> The first page is the login page. Right now, the initialization 
> happens in the visit.authenicate() method that the login page's 
> listener method invokes to validate a user's credentials using the 
> user's profile stored in a db table. If the login is successful, the 
> user sees the "main" page. The problem is that there is a delay in the 
> login and the appearence of the main page because of all the hibernate 
> initialization happening the very first time. This needs to be done 
> only once. Is there an engine method akin to servlet's init method 
> where I can do such one time initialization? What is a good place to 
> do this?
>
> Thanks
> Sohail Aslam
> Techlogix Inc.
> www.techlogix.com
>
>
>
> ---------------------------------------------------------------------
> 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: Hibernate initialization

Posted by Sohail Aslam <so...@techlogix.com>.
Thanks Howard, that did it.
Sohail
www.techlogix.com

Howard M. Lewis Ship wrote:
> This is what application extensions are for. You could wrap this code up as a JavaBean and add an
> <extension> to your application specification. There's an attribute to force the creation of the
> bean at application initialization.
> 
> --
> Howard M. Lewis Ship
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry
> http://jakarta.apache.org/commons/sandbox/hivemind/
> http://javatapestry.blogspot.com
> 




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


RE: Hibernate initialization

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
This is what application extensions are for. You could wrap this code up as a JavaBean and add an
<extension> to your application specification. There's an attribute to force the creation of the
bean at application initialization.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Sohail Aslam
> Sent: Saturday, September 27, 2003 2:47 AM
> To: tapestry-user@jakarta.apache.org
> Subject: Hibernate initialization
> 
> 
> I am attempting to use hibernate in a tapestry-based application. I 
> would like to carry out hibernate related initialization *before* the 
> very first html (home) page appears, i.e., I want the following to 
> happen before the the user sees the first page of the application.
> 
>             Configuration cfg = new Configuration();
>              cfg.addClass(com.cgc.esd.pages.csys.User.class)
>                 .addClass(com.cgc.esd.pages.csys.Application.class)
>                 .addClass(com.cgc.esd.pages.csys.Actor.class)
>                 .addClass(com.cgc.esd.pages.csys.Usecase.class)
>                 .addClass(com.cgc.esd.pages.csys.Role.class)
>                 .addClass(com.cgc.esd.pages.csys.Responsibility.class)
>                 .addClass(com.cgc.esd.pages.cinv.Buyer.class)
>                 
> .addClass(com.cgc.esd.pages.cinv.BuyerCompositeID.class)
>                 ;
>              Properties properties=new Properties();
>              properties.load(HUtil.class.
>                 getResourceAsStream("/hibernate.properties"));
>              cfg.setProperties(properties);
>              sessionFactory=cfg.buildSessionFactory();
> 
> The first page is the login page. Right now, the 
> initialization happens 
> in the visit.authenicate() method that the login page's 
> listener method 
> invokes to validate a user's credentials using the user's 
> profile stored 
> in a db table. If the login is successful, the user sees the "main" 
> page. The problem is that there is a delay in the login and the 
> appearence of the main page because of all the hibernate 
> initialization 
> happening the very first time. This needs to be done only 
> once. Is there 
> an engine method akin to servlet's init method where I can do 
> such one 
> time initialization? What is a good place to do this?
> 
> Thanks
> Sohail Aslam
> Techlogix Inc.
> www.techlogix.com
> 
> 
> 
> ---------------------------------------------------------------------
> 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