-->
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: Multiple Session per Request Transaction w/ EJB 2.1 CMT
PostPosted: Sun Sep 11, 2011 8:03 pm 
Newbie

Joined: Tue Aug 05, 2008 3:11 pm
Posts: 7
Hello experts:
Our j2ee application environment includes: EJB 2.1 CMT on RAD 7.5 (websphere 7.0) and hibernate 3.6.

In hibernate.cfg.xml, hibernate.transaction.factory_class = org.hibernate.transaction.CMTTransactionFactory,
transaction.manager_lookup_class = org.hibernate.transaction.WebSphereTransactionManagerLookup

We have an EJB 2.1 session bean with method named: processData(), which calls DAO's processData() method that uses hibernate. Codes in MyDAO.java:

private void processData() {
List list = getData();
UpdateRows(List list);
}

private void getData() {
try {
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();

// get data //
session.flush();
catch (HibernateException e) {
} finally {
closeSession();
}
}

private void UpdateRows() {
try {
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();

// do update //
session.flush();
catch (HibernateException e) {
} finally {
closeSession();
}
}

Assume that
1) sf.getCurrentSession() can not used
2) getData() and updateRows() can not be placed in the same methods due to our business requirements.
3) getData() and updateRows() methods (i.e. processData() method) must be in a single transaction.

My question is:
By using multiple hibernate sessions (especially, open multiple sessions), will the getData() and updateRows() methods be guaranteed in the SAME transaction by CMT or not?
Any problem or suggestion?

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.