Spring的事务实现采用基于AOP的拦截器来实现,如果没有在事务配置的时候注明回滚的checked exception,那么只有在发生了unchecked exception的时候,才会进行事务回滚。因此在DAO层和service层,最好抛出unckecked exception.
Checked exception 是在编译时在语法上必须处理的异常,因此必须在语法上以try..catch加以处理;
Unchecked exception是运行时异常,它继承java.lang.RuntimeException
DataAccessException 就属于RuntimeException
Checked exception 是在编译时在语法上必须处理的异常,因此必须在语法上以try..catch加以处理;
Unchecked exception是运行时异常,它继承java.lang.RuntimeException
DataAccessException 就属于RuntimeException