Announcement Announcement Module
Collapse
No announcement yet.
Transaction not rollbacked Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction not rollbacked

    Hi

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

    My class

    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
    You need to provide more details: the transactional configuration and where are you calling that method from.

    Also, please note that we are currently in the process of moving to stackoverflow.com for our forums. You might consider posting this question/issue at http://stackoverflow.com using the #spring tag and someone should be able to help you. Thanks!

    Comment


    • #3
      thransaction configuration is already there

      saleFacade.update is called in a loop. this method call renewSale. In renewSale, xxx.renewSpecialSale() is called and there are an error who are trowed. I would like to rollback the action done in the method.

      Comment

      Working...
      X