Spring @Transcational注解使用注意事项

@Transcational

  • @Transcational只有对public方法生效

  • @Transcational(readOnly=true)

    	`readOnly`而是将标志作为提示传播到底层JDBC驱动程序,以进行性能优化。
    

    Spring在基础JPA提供程序上执行了一些优化

    For example, when used with Hibernate, the flush mode is set to NEVER when you configure a transaction as readOnly, which causes Hibernate to skip dirty checks (a noticeable improvement on large object trees).

    意义:主要是让数据库放弃了 redo log日志的记录,提高效率

  • 同一个类 中没有事务控制的方法调用另外一个@Transcational标记的方法,会让事务注解标记失效

  • 事务的传播机制

    • required default
    • requires_new
    • supports
    • not_supported
    • never
    • nested
    • mandatory
  • 事务的隔离级别

    • 读取未提交 ->丢失修改

    • 读取已提交-> 脏读

    • 可重复读 ->不可重复读

    • 串行化 ->幻读

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值