Mybatis学习第14节 -- 一级缓存被刷新的情况

测试

@Test
public void testCacheLevelOne1() {
SqlSession session = MyBatisUtil.getSqlSession();
ShopMapper mapper = session.getMapper(ShopMapper.class);
Shop shop = mapper.getShopById(1);
System.out.println(shop);
// update
shop.setName("new "+shop.getName());
mapper.updateShopBySet(shop);


// session = MyBatisUtil.getSqlSession();
// mapper = session.getMapper(ShopMapper.class);
// // select again
System.out.println(mapper.getShopById(1));
session.close();
}
结果
2018-12-28 17:10:40,900 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - ==> Preparing: select * from tb_shop where `shop_id` = ? 
2018-12-28 17:10:41,106 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - ==> Parameters: 1(Integer)
2018-12-28 17:10:41,296 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - <== Total: 1
Shop{id=1, ownerId=1, areaId=3, categoryId=14, name='new 正式店铺名称', desc='测试描述', addr='正式地址', phone='13810524086', image='/upload/item/shop/1/2017091621545314507.jpg', priority=10, createTime=2017-08-03, lastEditTime=2017-09-16, enableStatus=0, advice='审核中'}

2018-12-28 17:10:41,427 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.updateShopBySet] - ==> Preparing: UPDATE `tb_shop` SET `shop_name` = ?, `shop_desc` = ? WHERE `shop_id` = ? ; 
2018-12-28 17:10:41,435 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.updateShopBySet] - ==> Parameters: new new 正式店铺名称(String), 测试描述(String), 1(Integer)
2018-12-28 17:10:41,446 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.updateShopBySet] - <== Updates: 1
2018-12-28 17:10:41,447 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - ==> Preparing: select * from tb_shop where `shop_id` = ? 
2018-12-28 17:10:41,447 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - ==> Parameters: 1(Integer)
2018-12-28 17:10:41,454 [main] DEBUG [io.github.coinsjack.dao.ShopMapper.getShopById] - <== Total: 1
Shop{id=1, ownerId=1, areaId=3, categoryId=14, name='new new 正式店铺名称', desc='测试描述', addr='正式地址', phone='13810524086', image='/upload/item/shop/1/2017091621545314507.jpg', priority=10, createTime=2017-08-03, lastEditTime=2017-09-16, enableStatus=0, advice='审核中'}
 
结论
虽然进行了更新, 但是没有提交, 但是缓存还是被flush了

转载于:https://www.cnblogs.com/litran/p/10545869.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值