使用@Transactional时候的注意点
使用@Transactional时候的注意点: 1.确认有如下配置:<tx:annotation-driven transaction-manager="transactionManager"/> 2.readOnly能不用就不能 3.嵌套事务中尽量少用REQUIRED_NEW,除非某些操作无论如何都要持久化 4.只有uncheck exception才会使事务回滚,checked exception不会使用回滚。如果要在checked exception中让事务回滚,则有如下方法: a)在属性rollbackFor中增加unchecked exception,如:@Transactional(rollbackFor={Exception.class}) b)手工把checked exception默译成unchecked exception