随笔分类 -  MyBatis(Plus)

摘要:1,批量添加 批量插入数据使用的sql语句是: insert into table (字段一,字段二,字段三) values(xx,xx,xx),(oo,oo,oo) mapper文件: int insertBatch(List<TmApplyTemplateDetail> applyTemplat 阅读全文
posted @ 2020-08-04 11:14 风子磊 阅读(7562) 评论(4) 推荐(0)
摘要:主要适用场景 意图: 当要更新一条记录的时候,希望这条记录没有被别人更新 乐观锁实现方式: 取出记录时,获取当前version 更新时,带上这个version 执行更新时, set version = newVersion where version = oldVersion 如果version不对 阅读全文
posted @ 2020-07-30 10:59 风子磊 阅读(289) 评论(0) 推荐(0)
摘要:一,基本查询 //测试查询By Id @Test public void testselectById(){ TUser tUser = tUserMapper.selectById(1L); System.out.println(tUser); } // 测试批量查询!By ids @Test p 阅读全文
posted @ 2020-07-30 10:56 风子磊 阅读(2704) 评论(0) 推荐(0)
摘要:1,继承MetaObjectHandler 2,注解填充字段 @TableField(.. fill = FieldFill.INSERT) 生成器策略部分也可以配置! @TableField(fill = FieldFill.INSERT) private Date createTime; @Ta 阅读全文
posted @ 2020-07-29 10:59 风子磊 阅读(1427) 评论(0) 推荐(0)
摘要:一,创建SpringBoot项目 二,引入依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.5</version> </dep 阅读全文
posted @ 2020-07-07 13:56 风子磊 阅读(160) 评论(0) 推荐(0)