I know how to write this with annotations:
@ Transactional (rollbackFor= {RuntimeException.class, Exception.class})
so how to configure it with xml?
:CustomExceptionException
TbProduct product = this.addProduct(dto, user);
if(1==1){
throw new CustomException(9999,"test");
}
according to the configuration below, if an error is reported during the running of the program, it will not be rolled back (CustomException is supposed to be a subclass of Exception, but the rollback is only caused by CustomException, but if there is a problem with my rollback-for= "Exception", the above addProduct () will not be rolled back)
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- -->
<tx:method name="*" rollback-for="com.mal.vo.CustomException" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="select*" propagation="SUPPORTS" read-only="true" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>