-->
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: Howto Rollback? (Cannot rollback during a managed transactio
PostPosted: Thu Nov 18, 2004 3:20 pm 
Newbie

Joined: Fri Nov 05, 2004 7:30 am
Posts: 2
Location: Florian
Hibernate version: 2.1.6

Name and version of the database you are using: Oracle 8i

Hi all,

I am doing just a simulation operation in my db, and after the process i need to rollback all that was generated:
Code:
public Object simulate(...) {
  Object ret = null;
  Connection con = null;
  Transaction trans = null;
  Session session = null; 
  beginSession();
  try {
    trans = session.beginTransaction();
    con = session.connection();
    ret = calculate(con); // <<<<< legacy method that uses a Connection object
  } catch (Exception e) {
    e.printStackTrace();
  } finally {
    try {
      trans.rollback(); // <<<<< the exception occurs here
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      endSession();
    }
  }
  return ret;
}

public Object calculate(Connection con) {
  // performs all the processing over db
}

But I am getting this exception:
java.sql.SQLException: You cannot rollback during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcRollback(BaseWrapperManagedConnection.java:537)
at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedConnection.java:483)
at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:86)
at br.com.softplan.saj.sgmp.dao.hbn.HbnCalculocustaDAO.simuleCustas(HbnCalculocustaDAO.java:411)
at br.com.softplan.saj.sgmp.ejb.impl.CalculocustaBean.simuleCustas(CalculocustaBean.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:111)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:709)
...


How can I rollback the transaction??

_________________
________________
Henrique Viecili


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.