问题场景:
同一个类中,无事务方法invokeInsertThenRollback()中调用有事务方法insertThenRollback(),结果事务失效,没有回滚,数据正常写入到数据表。
解决方案:
第一种解决方案:在invokeInsertThenRollback()方法上加@Transactional;
第二种解决方案:将调用方法invokeInsertThenRollback()和被调方法insertThenRollback()不要放在同一个类中,分开写在两个类里面;
原因分析:
参考:https://www.cnblogs.com/softidea/p/5962597.html
或者百度自行搜索此类场景问题。