ssh批量添加问题,听祖先说,标题要长,大哥大姐才会进来
spring config(其中关键2条):
<tx:method name="*" rollback-for="Exception" propagation="REQUIRED" />
<aop:pointcut expression="execution(* com..*.service..*.*(..))" id="methods"/>
然后我再service层写实现代码:
for (int i = 0; i < entity.size(); i++) {
if(i==10){
throw new Exception();
}
b = super.save(entity.get(i));
}
在执行第10行的时候手动抛出异常,但是前10条还是进数据库了。
我要怎么做,当有异常的时候让前10条不进数据库呢。