in simple Session Bean running in JBoss I tested Hibernate with
MySql-Database. According to the usual I did something like this:
Session l_sess = null;
Transaction l_tx = null;
try {
l_sess = HibernateUtil.getInstance().getSession();
l_tx =l_sess.beginTransaction();
l_list = getAllAuctionInfos(l_sess);
l_tx.commit();
this last statement causes an exception to be thrown :
java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:525)
at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:473)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:63)
at org.hibernate.auction.ejb.HibernateAuctionBean.viewAllAsAuctionInfo(HibernateAuctionBean.java:110)
Why is this thrown? I thought Hibernate would synchronize with the
container transaction.
Any ideas?
Carlo Luib-Finetti