AnsweredAssumed Answered

How to interrupt(stop) the transction while doing the process of save(),update() or merge()(i.e beginTransaction---commit())

Question asked by stsivaraj on Nov 27, 2013
Latest reply on Nov 28, 2013 by trademak
I have to interrupt(stop) the tranaction when its take longer time. I am using thread local to create new session per request.
   The process is one request to create the session and commit the transaction. Meanwhile i need to interrupt the transaction after
   transaction is created.

      Session session = HibernateSessionFactory.createNewSession();
      Transaction tran=session.beginTransaction();
      …………….
      ……………   
      tran.commit();
   My requirement is , i have sent one more request to cancel the transaction. If the transaction is already completed, i just ignore the cancel.
   Otherwise, i need to stop the tranasction if it will take longer time.   
      Session session = HibernateSessionFactory.createNewSession();
      Transaction tran=session.beginTransaction();
      …………….
      ……………//Need to stop the transaction before commit!
      ……………   
      tran.commit();
   Is it possible? How to achieve this work?

Outcomes