spring data jpa @Transactional

/**

1,server层加Transactional

2,项目框架为Spring boot

*/

@Transactional(rollbackFor = Exception.class)

@Service

public class xxServiceImpl implements xxService {

}

需要考虑的点:

1,RuntimeException 和checkedException的定义,以及有哪些具体的异常

Checked Exception(非Runtime Exception

Unchecked ExceptionRuntime Exception

 

2,@Transactional(rollbackFor = Exception.class) 默认回滚的异常是什么    //RuntimeException。加了rollBackFor属性后,又是如何限定

 

3,事务回滚的代码逻辑

@Transactional(rollbackFor = Exception.class)
public void testSysConfig1(SysConfigEntity entity) throws Exception {
     //会回滚
     this.saveSysConfig(entity);
     throw new Exception("sysconfig error");
}    

@Transactional
public void testSysConfig2(SysConfigEntity entity) throws Exception {
    //会回滚
     this.saveSysConfig(entity);
     throw new RuntimeException("sysconfig error");
}

参考的链接:我遇到的JPA中事务回滚的问题

4,待定

 

 

你可能感兴趣的:(spring,data,jpa)