@Transactional注解的属性
时间: 2023-10-17 07:32:49 浏览: 94
@Transactional注解有几个常用的属性,包括propagation、isolation、timeout、readOnly、rollbackFor和noRollbackFor。其中,propagation属性指定事务的传播行为,可以设置为REQUIRED、SUPPORTS、MANDATORY、REQUIRES_NEW、NOT_SUPPORTED、NEVER或者NESTED。isolation属性指定事务的隔离级别,可以设置为DEFAULT、READ_UNCOMMITTED、READ_COMMITTED、REPEATABLE_READ或者SERIALIZABLE。timeout属性指定事务的超时时间,单位为秒。readOnly属性指定事务是否为只读事务,如果设置为true,则表示只读事务,否则为读写事务。rollbackFor属性指定需要回滚的异常类型,可以设置为某个具体的异常类或者异常类的数组。noRollbackFor属性指定不需要回滚的异常类型,同样可以设置为某个具体的异常类或者异常类的数组。需要注意的是,如果同时使用类级别和方法级别的@Transactional注解,方法级别的注解会覆盖类级别的注解的配置信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [java 注解之@Transactional 注解](https://blog.csdn.net/jack_bob/article/details/106638674)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [事务解答之@Transactional 注解的属性介绍](https://blog.csdn.net/cm15835106905/article/details/107879217)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文