`

mybatis-plus事务使用

阅读更多

service实现类

@Service

@Transactional(propagation=Propagation.NESTED,isolation=Isolation.DEFAULT,readOnly = false,rollbackFor=RestException.class)

//加在类上面,下面方法默认都按这个,不使用可以再在方法上填写覆盖

//事务传播属性为嵌套:如果没有,就新建一个事务;如果有,就在当前事务中嵌套其他事务

//Isolation.DEFAULT,事务隔离级别使用数据库默认

public class RepoServiceImpl extends ServiceImpl<RepoMapper, Repo> implements IRepoService {

 

private final Logger log = LoggerFactory.getLogger(this.getClass());

@Autowired

private IRepoLockService repoLockService;

@Autowired

private IRepoManagerRelService repoManagerRelService;

 

@Autowired

private RepoMapper repoMapper;

 

 

@Transactional(readOnly = true) //查询设置为只读事务:这样不加锁

public Page<RepoCapacity> queryRepoInfo

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics