@GetMapping(value = "/health")
@Transactional
public String health(){
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
PhotoPropertyDO photoPropertyDO = new PhotoPropertyDO();
photoPropertyDO.setId("123");
photoPropertyDO.setSource("123");
photoPropertyDO.setPhotoId("123");
photoPropertyDO.setPropertyType("orderNum");
photoPropertyDO.setPropertyValue("123");
photoPropertyDO.setSearchIndexType(1);
photoPropertyDO.setDeleted(1);
photoPropertyDO.setCreateTime(new Date());
photoPropertyDO.setUpdateTime(new Date());
photoPropertyDao.insert(photoPropertyDO);
return JsonUtils.toJSONString(new HealthVO(applicationName));
}
@GetMapping(value = "/test")
@Transactional
public String test(){
while (true){
PhotoPropertyDOExample photoPropertyDOExample = new PhotoPropertyDOExample();
photoPropertyDOExample.createCriteria().andPhotoIdEqualTo("123");
List<PhotoPropertyDO> photoPropertyDOList = photoPropertyDao.selectByExample(photoPropertyDOExample);
System.out.println("查询的结果是"+JsonUtils.toJSONString(photoPropertyDOList));
}
}
两个事务,一个事务插入了数据,另一个事务一直查询不到。
原因是可重复读事务隔离级别,查询的一直是事务开启时的快照