Register / Login
Win a copy of
The Business Blockchain
this week in the
Object Relational Mapping
Implementing Hibernate Session per Request using EJB CMT
posted 7 years ago
I'm looking for a few pointers on implementing the hibernate session per request
for the following scenario,
The environment will consist of Spring 2.0, Hibernate 3.x, and
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
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,
Confusion between Entity and Session Bean
Webservice & EJB
Caching in Hibernate
Hibernate and EJB
Hibernate connection close issue.