Results 1 to 2 of 2
  1. #1
    collin is offline Member
    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    Default Transaction not rollbacked

    Hi

    I have a set of operation i would like to be rollbacked if there are an error.

    My class

    Java Code:
    public class BSException extends RuntimeException{
      ...
    }
    
    public class saleFacade{
    
      public update(){
    
        for (){
          try{
        renewSale();
          }
          catch(BSException){
        logger.error();
          }
        }
      }
    
      @Transactional
      public renewSale(){
        try{
          findSale(); // read only Transactional
          xxx.renewSpecialSale();
        }
        catch(BSException){
        logger.error(...);
        }
      }
    
    }
    
    
    public class xxx(){
      public void renewSpecialSale(){    
        payFee(); //write to db
        if(error){
          throw new BSException();
        }
      }
    
      @Transactional(propagation = Propagation.REQUIRED)
      public payFee(){
        ...
      }
    
    }
    
    @Configuration
    @EnableTransactionManagement
    public class DBConfiguration{
      @Bean(name = "dataSource")
      public BasicDataSource dataSource(){
        ...
      }
    }
    In the renewSale method, if there is an error, i would like to rollback.
    Right now nothing is rollbacked

    any idea?

  2. #2
    Join Date
    Apr 2014
    Posts
    48
    Rep Power
    0

    Default Re: Transaction not rollbacked

    are you using something like @Transactional(rollbackFor = Exception.class) ?

Similar Threads

  1. Am I using transaction correctly?
    By Jack_Tauson_Sr in forum JDBC
    Replies: 8
    Last Post: 04-14-2014, 02:11 PM
  2. ATM machine Transaction
    By udscrick in forum Advanced Java
    Replies: 1
    Last Post: 12-18-2011, 01:49 PM
  3. Error during execution, transaction rollbacked.
    By seal0rd in forum New To Java
    Replies: 1
    Last Post: 10-27-2011, 02:03 PM
  4. EJB Transaction Problem
    By kembljoe in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 12-17-2009, 12:04 PM
  5. jsp:include in a sql:transaction
    By sam2020 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-31-2008, 08:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •