-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Newbie: Best way to access SessionFactory from an EJB
PostPosted: Tue Oct 21, 2003 12:46 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
I'm a newbie at J2EE, and refactoring an existing Hibernate/Tomcat/Struts app, and I'd like to know the best method for obtaining a session within a Stateless Session Bean. Currently, I'm doing it as outlined in the Wiki:

Context ctx = new InitialContext();
SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/HibernateFactory");
sess = factory.openSession();

Which is working fine, but is this the preferred way to do it in production environments? How expensive is the JNDI lookup for this? Is it possible (or worthwhile) to cache the SessionFactory reference somewhere so I don't have to do the lookup each time? What's the best practice for this?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.