ITeye博客

使用@Transactional时候的注意点

jakoes · 2010-10-11 18:21 · Java相关 · 企业架构 · Markdown

使用@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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。