Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Implementing Hibernate Session per Request using EJB CMT

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm looking for a few pointers on implementing the hibernate session per request pattern for the following scenario,

The environment will consist of Spring 2.0, Hibernate 3.x, and EJB 2.1 [with CMT]

The problem involves an EJB method which calls a number of methods involving several DAO's that insert/read from the database.

In this instance we'd be using CMT configured through the deployment descriptor with app values for propagation.

I'd like to use the same Hibernate session for all database access operations.

Having looked through the hibernate documentation, I've figured that I need to set the following properties

i.) hibernate.transaction.factory_class = org.hibernate.transaction.CMTTransactionFactory

ii.)hibernate.transaction.manager_lookup_class=org.hibernate.transaction.WeblogicTransactionManagerLookup

iii.) hibernate.current_session_context_class = thread [Do I need this?]

iv.)Finally, in my DAOs [all extending HibernateDaoSupport) would I have to replace all references of HibernateTemplate with app calls to sessionFactory.getCurrentSession(), e.g.

getHibernateTemplate().find(...) with this.getSessionFactory().getCurrentSession().find(...) etc.

Is this all I need to do or am I on the wrong track?

thanking you in advance,

Nick

 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic