Good morning,
I'm using an app thats has org.hibernate.transaction.JDBCTransactionFactory to manage the transaction. In addition, this app do not use EJB for managed only use Hibernate and sessionFactory. In each method has something like this :
try { HibernateUtil.beginTransaction(); HibernateUtil.getCurrentSession().setFlushMode(FlushMode.MANUAL); List<xx> list= XXxDAO.INSTANCE.getObjetctByData(id,name); HibernateUtil.commitCurrentTransaction(); return list; } finally { HibernateUtil.closeCurrentSession(); }
In my opinion, if I use org.hibernate.transaction.JDBCTransactionFactory and I am not use JTA, then the Transactions aren't managed for JEE, then the session are open and close in each method and not for request, or another option. In the other hand, I have a problem that in a SELECT has a commit, so, I am not sure is the correct way to use, I'will use a closetransaccion, the commit option. I will use only if I have a modify, delete or insert.
Which is your opinion?
|