Configuration().configure().buildSessionFactory() in StartupListener creates the Hibernate SessionFactory;
InitialContext().lookup(Constants.SESSION_FACTORY) in ServiceLocator retrieves the SessionFactory. --- lixin chu <[EMAIL PROTECTED]> wrote: > Hi, > I have question after reading AppFuse example - but > I > hope that the question is generic enough for posting > in this forum. Sorry if it is not. > > AppFuse has a StartupListener.java which initialize > Hibernate using: > > Configuration().configure().buildSessionFactory(); > So to support this, we need Hibernate.cfg.xml. > > Then AppFuse has a ServiceLocator.java, which > manages > sessions. When instantiating ServiceLocator, we have > this: > (SessionFactory) sf = > InitialContext().lookup(Constants.SESSION_FACTORY); > > My understanding is that we need to now bind > SessionFactory with JNDI to support the above call > (in > server.xml file). > > Here are my questions: > 1) why do we initialze Hibernate in two places > (ServiceLocator and StartupListener)? I thought we > should only do this once. > > 2) Tomcat has problems supporting JNDI binding for > Hibernate session factory. Will the above > InitialContext() work ? > > 3) Since StartupListener has already initialized the > Hibernate SessionFactory, should I put it in > ServletContext so ServiceLocator can retrieve it > later > instead of using InitialContext ? > > thanks > li xin > > > > __________________________________ > Do you Yahoo!? > Yahoo! Search - Find what you抮e looking for faster > http://search.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

