Spring整合注解随笔20

44 阅读1分钟

MyBatis 动态SQL

if、where 标签

where 标签会自动解决多了and的sql语句

image.png

set标签和where标签类似,都是解决语法问题,解决多余的逗号

trim 自定义截串规则,可以代替where和set标签

image.png

或用| 或者|| 都可以

image.png

choose/when/otherwise 标签

when第一个生效

image.png

foreach标签

image.png

image.png

image.png

但是传空会报错

优化:

image.png

批量插入

image.png

image.png

批量修改

image.png

image.png

数据库支持多个插入

image.png

image.png

开启事务

image.png

image.png

sql片段

image.png

image.png

特殊字符

image.png

image.png

Mybatis扩展

拥有二级缓存机制,用来加速查询

image.png

image.png

image.png

image.png

同时,对象需要实现序列化接口

image.png

后来几乎不用了

image.png

PageHelper分页插件

image.png