-->
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.  [ 3 posts ] 
Author Message
 Post subject: Simplest route to Integrating Hibernate with EJBs?
PostPosted: Tue Jun 08, 2004 4:52 am 
Newbie

Joined: Sun May 09, 2004 6:03 am
Posts: 3
What is the simplest route to integrating Hibernate with Session beans? I have read articles on the thread local pattern but I do not want to go down this route.

I want to use the container's database connection so that container managed transactions will be used but at the same time I want to reuse/cache as much of Hibernate as possible to improve performance.

I am looking to cache the SessionFactory only whilst wrapping all database activity within the scope of a single session method call.

Is this strategy a standard pattern for Hibernate and EJBs?

Thanks,

Myles


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 6:34 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
If you don't want or don't need to use the Hibernate Pattern.
You can use a simple session Facade with a servicelocator.
That's the easiest way to integrate Hibernate into a J2EE architechture.
Kind regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 8:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well the simpliest way to "reuse" the SessionFactory in J2EE containers is to either 1) bind the SessionFactory into JNDI (see the xml config docs for info on how to do this); or 2) utilize a singleton helper class which manages the SessionFactory reference.

If you do not like the ThreadLocalPattern, then you need to come up with a way for the helper classes of your EJBs to have access to the session bound to the current call. But first, you'd have to determine how the session is to get bound to the context of the current call. Something like the Springframework or PicoContainer can help here. I've used Hibernate and Spring together in conjunction with EJBs and it worked really well. The best part was the ability to take the code outside of the J2EE container and run it (for, say, testing purposes).


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

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.