mybatisplus筆記

basemapper接口

mybatisplus筆記

@TableId批注

mybatisplus筆記

如果表里和字段里名称不一致,需要value来指定

mybatisplus筆記

mybatisplus筆記

@TableName批注

mybatisplus筆記

全局策略配置 

mybatisplus筆記        mybatisplus筆記        mybatisplus筆記需要把globalConfiguration注入到sqlsessionFactory 里

mybatisplus筆記

插入操作

mybatisplus筆記

查询操作

id查询

mybatisplus筆記

mybatisplus筆記

由于jdk的大部分类都是实现了serializable接口的,所以就可以认为参数是Object的,可以传递任何类型的充当id

多个列查询

mybatisplus筆記

mybatisplus筆記

多个id查询

mybatisplus筆記

mybatisplus筆記

map封装条件查询

mybatisplus筆記

分页查询

mybatisplus筆記

mybatisplus筆記

mp启动注入sql原理:

sqlsession-> sqlsessionFactory-> Configuration -> MappedStatement -> sqlSource -> sql

条件构造器

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

condition

mybatisplus筆記

如何使用AR模式

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記

代码生成器

开启全局下划线开关mybatisplus筆記

mybatis代码生成会使用模板技术,默认使用的是velocity

mybatisplus筆記

mybatisplus筆記

gc.setActiveRecord(false);//是否支持AR模式,设置为true,生成的实体类会继承一个Model

gc.setFileOverride(true);//文件覆盖,第二次生成后是否覆盖第一次生成的文件

gc.setServiceName("%sService")  // 设置生成的service接口的名字的首字母是否为I                                                       // IEmployeeService 默认首字母会加i

.setBaseResultMap(true);      //基本的结果集映射

.setBaseColumnList(true);  //基本的列集合,sql片段

mybatisplus筆記

mybatisplus筆記

strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略,下划线转驼峯

 mybatisplus筆記

mybatisplus筆記

插件擴展

分頁插件

mybatisplus筆記

mybatisplus筆記

mybatisplus筆記