aspose file tools*
The moose likes Struts and the fly likes struts with hibernate. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts with hibernate." Watch "struts with hibernate." New topic
Author

struts with hibernate.

sure nandu
Greenhorn

Joined: Oct 16, 2006
Posts: 18
hai everybody,


iam a bit new to hibernates. so i did a simple application using hibernates in struts framework. i had not mentioned any plugin in struts-config.xml. but the application was working fine. iam very confused that how did the struts came to know about the location of
my hibernate.cfg.xml and mapping.hbm.xml. but both files was set in my classpath. if anybody knows the answer please inform.
thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As long as these files are in your classpath, Hibernate can find them.

The important thing to remember when using Hibernate in a web application is that creating the session factory is an expensive and resource intensive task, so you want to make sure you only perform it once and then create a reference to the session factory that you can retrieve somewhere.

One common approach when using Struts is to create a plugin and register it in the struts-config.xml file. This plugin then instatiates the session factory and puts it in Application scope so that it can be retrieved when it's needed.

Another approach is to create a singleton that stores the session factory as a static variable. Either way works.


Merrill
Consultant, Sima Solutions
sure nandu
Greenhorn

Joined: Oct 16, 2006
Posts: 18
thanks merill for yor detailed reply.

i will try to search a plugin.
 
jQuery in Action, 2nd edition
 
subject: struts with hibernate.