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
|