Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Hibernate Session per Request using EJB CMT

 
nicholas kershaw
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic