首页 > 编程语言 > 详细

springboot中l事务整理

时间:2020-11-20 23:47:46      阅读:61      评论:0      收藏:0      [点我收藏+]

事务的特性:原子性,持久性,隔离性,一致性

隔离级别(从低到高):               效果

读未提交,               不能防止  脏读 ,幻读, 不可重复读

读已提交                  能防止  脏读     不能防止   幻读, 不可重复读

,可重复读,             能防止  脏读  ,,不可重复读   不能防止   幻读, 

串行化                     能防止     脏读 , ,不可重复读   ,   幻读,

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Transactional {
@AliasFor("transactionManager")
String value() default "";

@AliasFor("value")
String transactionManager() default "";

String[] label() default {};

Propagation propagation() default Propagation.REQUIRED; //传播方式

Isolation isolation() default Isolation.DEFAULT; //隔离级别

// 隔离级别的枚举类

public enum Isolation {

DEFAULT(-1),
    READ_UNCOMMITTED(1),
READ_COMMITTED(2),
REPEATABLE_READ(4),
SERIALIZABLE(8);

private final int value;

private Isolation(int value) {
this.value = value;
}

public int value() {
return this.value;
}
}
使用方式:
public interface UsersDao {
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED)
List<Users> findAll();}







springboot中l事务整理

原文:https://www.cnblogs.com/yuandodo/p/14013378.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!