网站建设采购合同验收,东莞网站开发方案,广州百度推广电话,五莲网站建设维护推广1.项目介绍 2.项目背景介绍 3.项目商业模式介绍
4.项目功能模块介绍 5.项目技术点介绍 6.项目技术点-MybatisPlus介绍
官网#xff1a;http://mp.baomidou.com/
MyBatis-Plus#xff08;简称 MP#xff09;是一个 MyBatis 的增强工具#xff0c;在 MyBatis 的基础上只做…1.项目介绍 2.项目背景介绍 3.项目商业模式介绍
4.项目功能模块介绍 5.项目技术点介绍 6.项目技术点-MybatisPlus介绍
官网http://mp.baomidou.com/
MyBatis-Plus简称 MP是一个 MyBatis 的增强工具在 MyBatis 的基础上只做增强不做改变为简化开发、提高效率而生。
特性 无侵入只做增强不做改变引入它不会对现有工程产生影响如丝般顺滑 损耗小启动即会自动注入基本 CURD性能基本无损耗直接面向对象操作 强大的 CRUD 操作内置通用 Mapper、通用 Service仅仅通过少量配置即可实现单表大部分 CRUD 操作更有强大的条件构造器满足各类使用需求 支持 Lambda 形式调用通过 Lambda 表达式方便的编写各类查询条件无需再担心字段写错 支持多种数据库支持 MySQL、MariaDB、Oracle、DB2、H2、HSQL、SQLite、Postgre、SQLServer2005、SQLServer 等多种数据库 支持主键自动生成支持多达 4 种主键策略内含分布式唯一 ID 生成器 - Sequence可自由配置完美解决主键问题 支持 XML 热加载Mapper 对应的 XML 支持热加载对于简单的 CRUD 操作甚至可以无 XML 启动 支持 ActiveRecord 模式支持 ActiveRecord 形式调用实体类只需继承 Model 类即可进行强大的 CRUD 操作 支持自定义全局通用操作支持全局通用方法注入 Write once, use anywhere 支持关键词自动转义支持数据库关键词order、key…自动转义还可自定义关键词 内置代码生成器采用代码或者 Maven 插件可快速生成 Mapper 、 Model 、 Service 、 Controller 层代码支持模板引擎更有超多自定义配置等您来使用 内置分页插件基于 MyBatis 物理分页开发者无需关心具体操作配置好插件之后写分页等同于普通 List 查询 内置性能分析插件可输出 Sql 语句以及其执行时间建议开发测试时启用该功能能快速揪出慢查询 内置全局拦截插件提供全表 delete 、 update 操作智能分析阻断也可自定义拦截规则预防误操作 内置 Sql 注入剥离器支持 Sql 注入剥离有效预防 Sql 注入攻击
7.项目技术点-MybatisPlus入门案例1 1、引入依赖 spring-boot-starter、spring-boot-starter-test 添加mybatis-plus-boot-starter、MySQL、lombok、 在项目中使用Lombok可以减少很多重复代码的书写。比如说getter/setter/toString等方法的编写
dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scopeexclusionsexclusiongroupIdorg.junit.vintage/groupIdartifactIdjunit-vintage-engine/artifactId/exclusion/exclusions/dependency!--mybatis-plus--dependencygroupIdcom.baomidou/groupIdartifactIdmybatis-plus-boot-starter/artifactIdversion3.0.5/version/dependency!--mysql--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId/dependency!--lombok用来简化实体类--dependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/dependency
/dependencies注意引入 MyBatis-Plus 之后请不要再次引入 MyBatis 以及 MyBatis-Spring以避免因版本差异导致的问题。
2、idea中安装lombok插件 1idea2018版本 配置 在 application.properties 配置文件中添加 MySQL 数据库的相关配置 mysql5
#mysql数据库连接
spring.datasource.driver-class-namecom.mysql.jdbc.Driver
spring.datasource.urljdbc:mysql://localhost:3306/mybatis_plus
spring.datasource.usernameroot
spring.datasource.password123456mysql8以上spring boot 2.1 注意driver和url的变化
spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver
spring.datasource.urljdbc:mysql://localhost:3306/mybatis_plus?serverTimezoneGMT%2B8
spring.datasource.usernameroot
spring.datasource.password123456注意 1、这里的 url 使用了 ?serverTimezoneGMT%2B8 后缀因为Spring Boot 2.1 集成了 8.0版本的jdbc驱动这个版本的 jdbc 驱动需要添加这个后缀否则运行测试用例报告如下错误 java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more 2、这里的 driver-class-name 使用了 com.mysql.cj.jdbc.Driver 在 jdbc 8 中 建议使用这个驱动之前的 com.mysql.jdbc.Driver 已经被废弃否则运行测试用例的时候会有 WARN 信息
8.项目技术点-MybatisPlus入门案例2
1、主类 在 Spring Boot 启动类中添加 MapperScan 注解扫描 Mapper 文件夹 注意扫描的包名根据实际情况修改
SpringBootApplication
MapperScan(com.atguigu.mybatisplus.mapper)
public class MybatisPlusApplication {......
}2、实体 创建包 entity 编写实体类 User.java此处使用了 Lombok 简化代码
Data
public class User {private Long id;private String name;private Integer age;private String email;
}查看编译结果 Lombok使用参考https://blog.csdn.net/motui/article/details/79012846
3、mapper 创建包 mapper 编写Mapper 接口 UserMapper.java
public interface UserMapper extends BaseMapperUser {}六、开始使用 添加测试类进行功能测试
RunWith(SpringRunner.class)
SpringBootTest
public class MybatisPlusApplicationTests {Autowiredprivate UserMapper userMapper;Testpublic void testSelectList() {System.out.println((----- selectAll method test ------));//UserMapper 中的 selectList() 方法的参数为 MP 内置的条件封装器 Wrapper//所以不填写就是无任何条件ListUser users userMapper.selectList(null);users.forEach(System.out::println);}
}注意
IDEA在 userMapper 处报错因为找不到注入的对象因为类是动态创建的但是程序可以正确的执行。 为了避免报错可以在 dao 层 的接口上添加 Repository 注
控制台输出
User(id1, nameJone, age18, emailtest1baomidou.com)
User(id2, nameJack, age20, emailtest2baomidou.com)
User(id3, nameTom, age28, emailtest3baomidou.com)
User(id4, nameSandy, age21, emailtest4baomidou.com)
User(id5, nameBillie, age24, emailtest5baomidou.com)通过以上几个简单的步骤我们就实现了 User 表的 CRUD 功能甚至连 XML 文件都不用编写
七、配置日志
#mybatis日志
mybatis-plus.configuration.log-implorg.apache.ibatis.logging.stdout.StdOutImpl9.项目技术点-MybatisPlus添加操作
插入操作
RunWith(SpringRunner.class)
SpringBootTest
public class CRUDTests {Autowiredprivate UserMapper userMapper;Testpublic void testInsert(){User user new User();user.setName(Helen);user.setAge(18);user.setEmail(55317332qq.com);int result userMapper.insert(user);System.out.println(result); //影响的行数System.out.println(user); //id自动回填}
}注意数据库插入id值默认为全局唯一id
10.项目技术点-MybatisPlus主键生成策略介绍 1ID_WORKER MyBatis-Plus默认的主键策略是ID_WORKER 全局唯一ID 参考资料分布式系统唯一ID生成方案汇总https://www.cnblogs.com/haoxinyue/p/5208136.html
2自增策略 要想主键自增需要配置如下主键策略 需要在创建数据表的时候设置主键自增 实体字段中配置 TableId(type IdType.AUTO)
TableId(type IdType.AUTO)
private Long id;要想影响所有实体的配置可以设置全局主键配置
#全局设置主键生成策略
mybatis-plus.global-config.db-config.id-typeauto其它主键策略分析 IdType 源码可知
Getter
public enum IdType {/*** 数据库ID自增*/AUTO(0),/*** 该类型为未设置主键类型*/NONE(1),/*** 用户输入ID* 该类型可以通过自己注册自动填充插件进行填充*/INPUT(2),/* 以下3种类型、只有当插入对象ID 为空才自动填充。 *//*** 全局唯一ID (idWorker)*/ID_WORKER(3),/*** 全局唯一ID (UUID)*/UUID(4),/*** 字符串全局唯一ID (idWorker 的字符串表示)*/ID_WORKER_STR(5);private int key;IdType(int key) {this.key key;}
}11.项目技术点-MybatisPlus实现自动填充 1、根据Id更新操作 注意update时生成的sql自动是动态sqlUPDATE user SET age? WHERE id? Testpublic void testUpdateById(){User user new User();user.setId(1L);user.setAge(28);int result userMapper.updateById(user);System.out.println(result);}2、自动填充 项目中经常会遇到一些数据每次都使用相同的方式填充例如记录的创建时间更新时间等。 我们可以使用MyBatis Plus的自动填充功能完成这些字段的赋值工作
1数据库表中添加自动填充字段 在User表中添加datetime类型的新的字段 create_time、update_time
2实体上添加注解
Data
public class User {......TableField(fill FieldFill.INSERT)private Date createTime;//TableField(fill FieldFill.UPDATE)TableField(fill FieldFill.INSERT_UPDATE)private Date updateTime;
}3实现元对象处理器接口 注意不要忘记添加 Component 注解
package com.atguigu.mybatisplus.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.Date;Component
public class MyMetaObjectHandler implements MetaObjectHandler {private static final Logger LOGGER LoggerFactory.getLogger(MyMetaObjectHandler.class);Overridepublic void insertFill(MetaObject metaObject) {LOGGER.info(start insert fill ....);this.setFieldValByName(createTime, new Date(), metaObject);this.setFieldValByName(updateTime, new Date(), metaObject);}Overridepublic void updateFill(MetaObject metaObject) {LOGGER.info(start update fill ....);this.setFieldValByName(updateTime, new Date(), metaObject);}
}12.项目技术点-MybatisPlus实现乐观锁1
主要适用场景当要更新一条记录的时候希望这条记录没有被别人更新也就是说实现线程安全的数据更新
乐观锁实现方式 1、取出记录时获取当前version 2、更新时带上这个version 3、执行更新时 set version newVersion where version oldVersion 4、如果version不对就更新失败 13.项目技术点-MybatisPlus实现乐观锁2
1数据库中添加version字段
ALTER TABLE user ADD COLUMN version INT2实体类添加version字段 并添加 Version 注解
Version
TableField(fill FieldFill.INSERT)
private Integer version;3元对象处理器接口添加version的insert默认值
Override
public void insertFill(MetaObject metaObject) {......this.setFieldValByName(version, 1, metaObject);
}特别说明: 支持的数据类型只有 int,Integer,long,Long,Date,Timestamp,LocalDateTime 整数类型下 newVersion oldVersion 1 newVersion 会回写到 entity 中 仅支持 updateById(id) 与 update(entity, wrapper) 方法 在 update(entity, wrapper) 方法下, wrapper 不能复用!!!
4在 MybatisPlusConfig 中注册 Bean 创建配置类
package com.atguigu.mybatisplus.config;import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;EnableTransactionManagement
Configuration
MapperScan(com.atguigu.mybatis_plus.mapper)
public class MybatisPlusConfig {//乐观锁插件 Beanpublic OptimisticLockerInterceptor optimisticLockerInterceptor() {return new OptimisticLockerInterceptor();}
}5测试乐观锁可以修改成功 测试后分析打印的sql语句将version的数值进行了加1操作
/*** 测试 乐观锁插件*/
Test
public void testOptimisticLocker() {//查询User user userMapper.selectById(1L);//修改数据user.setName(Helen Yao);user.setEmail(helenqq.com);//执行更新userMapper.updateById(user);
}5测试乐观锁修改失败
// 测试乐观锁插件 失败
Test
public void testOptimisticLockerFail() {//查询User user userMapper.selectById(1L);//修改数据user.setName(Helen Yao1);user.setEmail(helenqq.com1);//模拟取出数据后数据库中version实际数据比取出的值大即已被其它线程修改并更新了versionuser.setVersion(user.getVersion() - 1);//执行更新userMapper.updateById(user);
}14.项目技术点-MybatisPlus实现分页 根据id查询记录
Test
public void testSelectById(){User user userMapper.selectById(1L);System.out.println(user);
}通过多个id批量查询 完成了动态sql的foreach的功能
Test
public void testSelectBatchIds(){ListUser users userMapper.selectBatchIds(Arrays.asList(1, 2, 3));users.forEach(System.out::println);
}简单的条件查询 通过map封装查询条件
Test
public void testSelectByMap(){HashMapString, Object map new HashMap();map.put(name, Helen);map.put(age, 18);ListUser users userMapper.selectByMap(map);users.forEach(System.out::println);
}注意map中的key对应的是数据库中的列名。例如数据库user_id实体类是userId这时map的key需要填写user_id 分页 MyBatis Plus自带分页插件只要简单的配置即可实现分页功能
1.创建配置类 此时可以删除主类中的 MapperScan 扫描注解
//分页插件
Bean
public PaginationInterceptor paginationInterceptor() {return new PaginationInterceptor();
}2.测试selectPage分页 测试最终通过page对象获取相关数据 //分页查询Testpublic void testPage() {//1 创建page对象//传入两个参数当前页 和 每页显示记录数PageUser page new Page(1,5);//调用mp分页查询的方法//调用mp分页查询过程中底层封装//把分页所有数据封装到page对象里面userMapper.selectPage(page,null);//通过page对象获取分页数据System.out.println(page.getCurrent());//当前页System.out.println(page.getRecords());//每页数据list集合System.out.println(page.getSize());//每页显示记录数System.out.println(page.getTotal()); //总记录数System.out.println(page.getPages()); //总页数System.out.println(page.hasNext()); //下一页System.out.println(page.hasPrevious()); //上一页}控制台sql语句打印SELECT id,name,age,email,create_time,update_time FROM user LIMIT 0,5 15.项目技术点-MybatisPlus实现逻辑删除 1、根据id删除记录
Test
public void testDeleteById(){int result userMapper.deleteById(8L);System.out.println(result);
}2、批量删除 Testpublic void testDeleteBatchIds() {int result userMapper.deleteBatchIds(Arrays.asList(8, 9, 10));System.out.println(result);}3、简单的条件查询删除
Test
public void testDeleteByMap() {HashMapString, Object map new HashMap();map.put(name, Helen);map.put(age, 18);int result userMapper.deleteByMap(map);System.out.println(result);
}4、逻辑删除 物理删除真实删除将对应数据从数据库中删除之后查询不到此条被删除数据 逻辑删除假删除将对应数据中代表是否被删除字段状态修改为“被删除状态”之后在数据库中仍旧能看到此条数据记录
1数据库中添加 deleted字段
ALTER TABLE user ADD COLUMN deleted boolean2实体类添加deleted 字段 并加上 TableLogic 注解 和 TableField(fill FieldFill.INSERT) 注解
TableLogic
TableField(fill FieldFill.INSERT)
private Integer deleted;3元对象处理器接口添加deleted的insert默认值
Override
public void insertFill(MetaObject metaObject) {......this.setFieldValByName(deleted, 0, metaObject);
}4application.properties 加入配置 此为默认值如果你的默认值和mp默认的一样,该配置可无
mybatis-plus.global-config.db-config.logic-delete-value1
mybatis-plus.global-config.db-config.logic-not-delete-value05在 MybatisPlusConfig 中注册 Bean
Bean
public ISqlInjector sqlInjector() {return new LogicSqlInjector();
}6测试逻辑删除 测试后发现数据并没有被删除deleted字段的值由0变成了1 测试后分析打印的sql语句是一条update 注意被删除数据的deleted 字段的值必须是 0才能被选取出来执行逻辑删除的操作
//测试 逻辑删除
Test
public void testLogicDelete() {int result userMapper.deleteById(1L);System.out.println(result);
}7测试逻辑删除后的查询 MyBatis Plus中查询操作也会自动添加逻辑删除字段的判断
/*** 测试 逻辑删除后的查询* 不包括被逻辑删除的记录*/
Test
public void testLogicDeleteSelect() {User user new User();ListUser users userMapper.selectList(null);users.forEach(System.out::println);
}测试后分析打印的sql语句包含 WHERE deleted0 SELECT id,name,age,email,create_time,update_time,deleted FROM user WHERE deleted0
16.项目技术点-MybatisPlus性能分析
性能分析拦截器用于输出每条 SQL 语句及其执行时间 SQL 性能执行分析,开发环境使用超过指定时间停止运行。有助于发现问题
1、配置插件 1参数说明 参数maxTime SQL 执行最大时长超过自动停止运行有助于发现问题。 参数format SQL是否格式化默认false。
2在 MybatisPlusConfig 中配置
/*** SQL 执行性能分析插件* 开发环境使用线上不推荐。 maxTime 指的是 sql 最大执行时长*/
Bean
Profile({dev,test})// 设置 dev test 环境开启
public PerformanceInterceptor performanceInterceptor() {PerformanceInterceptor performanceInterceptor new PerformanceInterceptor();performanceInterceptor.setMaxTime(100);//ms超过此处设置的ms则sql不执行performanceInterceptor.setFormat(true);return performanceInterceptor;
}3Spring Boot 中设置dev环境
#环境设置dev、test、prod
spring.profiles.activedev可以针对各环境新建不同的配置文件application-dev.properties、application-test.properties、application-prod.properties 也可以自定义环境名称如test1、test2
2、测试 1常规测试
/*** 测试 性能分析插件*/
Test
public void testPerformance() {User user new User();user.setName(我是Helen);user.setEmail(helensina.com);user.setAge(18);userMapper.insert(user);
}2将maxTime 改小之后再次进行测试
performanceInterceptor.setMaxTime(5);//ms超过此处设置的ms不执行如果执行时间过长则抛出异常The SQL execution time is too large, 输出
17.项目技术点-MybatisPlus实现条件查询
一、wapper介绍 Wrapper 条件构造抽象类最顶端父类 AbstractWrapper 用于查询条件封装生成 sql 的 where 条件 QueryWrapper Entity 对象封装操作类不是用lambda语法 UpdateWrapper Update 条件封装用于Entity对象更新操作 AbstractLambdaWrapper Lambda 语法使用 Wrapper统一处理解析 lambda 获取 column。 LambdaQueryWrapper 看名称也能明白就是用于Lambda语法使用的查询Wrapper LambdaUpdateWrapper Lambda 更新封装Wrapper
RunWith(SpringRunner.class)
SpringBootTest
public class QueryWrapperTests {Autowiredprivate UserMapper userMapper;
}二、AbstractWrapper
注意以下条件构造器的方法入参中的 column 均表示数据库字段 1、ge、gt、le、lt、isNull、isNotNull
Test
public void testDelete() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.isNull(name).ge(age, 12).isNotNull(email);int result userMapper.delete(queryWrapper);System.out.println(delete return count result);
}SQLUPDATE user SET deleted1 WHERE deleted0 AND name IS NULL AND age ? AND email IS NOT NULL
2、eq、ne 注意seletOne返回的是一条实体记录当出现多条时会报错
Test
public void testSelectOne() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.eq(name, Tom);User user userMapper.selectOne(queryWrapper);System.out.println(user);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 AND name ?
3、between、notBetween 包含大小边界
Test
public void testSelectCount() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.between(age, 20, 30);Integer count userMapper.selectCount(queryWrapper);System.out.println(count);
}SELECT COUNT(1) FROM user WHERE deleted0 AND age BETWEEN ? AND ?
4、allEq
Test
public void testSelectList() {QueryWrapperUser queryWrapper new QueryWrapper();MapString, Object map new HashMap();map.put(id, 2);map.put(name, Jack);map.put(age, 20);queryWrapper.allEq(map);ListUser users userMapper.selectList(queryWrapper);users.forEach(System.out::println);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 AND name ? AND id ? AND age ?
5、like、notLike、likeLeft、likeRight selectMaps返回Map集合列表
Test
public void testSelectMaps() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.notLike(name, e).likeRight(email, t);ListMapString, Object maps userMapper.selectMaps(queryWrapper);//返回值是Map列表maps.forEach(System.out::println);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 AND name NOT LIKE ? AND email LIKE ?
6、in、notIn、inSql、notinSql、exists、notExists in、notIn notIn(“age”,{1,2,3})—age not in (1,2,3) notIn(“age”, 1, 2, 3)—age not in (1,2,3) inSql、notinSql可以实现子查询 例: inSql(“age”, “1,2,3,4,5,6”)—age in (1,2,3,4,5,6) 例: inSql(“id”, “select id from table where id 3”)—id in (select id from table where id 3)
Test
public void testSelectObjs() {QueryWrapperUser queryWrapper new QueryWrapper();//queryWrapper.in(id, 1, 2, 3);queryWrapper.inSql(id, select id from user where id 3);ListObject objects userMapper.selectObjs(queryWrapper);//返回值是Object列表objects.forEach(System.out::println);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 AND id IN (select id from user where id 3)
7、or、and 注意这里使用的是 UpdateWrapper 不调用or则默认为使用 and 连
Test
public void testUpdate1() {//修改值User user new User();user.setAge(99);user.setName(Andy);//修改条件UpdateWrapperUser userUpdateWrapper new UpdateWrapper();userUpdateWrapper.like(name, h).or().between(age, 20, 30);int result userMapper.update(user, userUpdateWrapper);System.out.println(result);
}UPDATE user SET name?, age?, update_time? WHERE deleted0 AND name LIKE ? OR age BETWEEN ? AND ?
8、嵌套or、嵌套and 这里使用了lambda表达式or中的表达式最后翻译成sql时会被加上圆括号
Test
public void testUpdate2() {//修改值User user new User();user.setAge(99);user.setName(Andy);//修改条件UpdateWrapperUser userUpdateWrapper new UpdateWrapper();userUpdateWrapper.like(name, h).or(i - i.eq(name, 李白).ne(age, 20));int result userMapper.update(user, userUpdateWrapper);System.out.println(result);
}9、orderBy、orderByDesc、orderByAsc
Test
public void testSelectListOrderBy() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.orderByDesc(id);ListUser users userMapper.selectList(queryWrapper);users.forEach(System.out::println);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 ORDER BY id DESC
10、last 直接拼接到 sql 的最后 注意只能调用一次,多次调用以最后一次为准 有sql注入的风险,请谨慎使用
Test
public void testSelectListLast() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.last(limit 1);ListUser users userMapper.selectList(queryWrapper);users.forEach(System.out::println);
}SELECT id,name,age,email,create_time,update_time,deleted,version FROM user WHERE deleted0 limit 1
11、指定要查询的列
Test
public void testSelectListColumn() {QueryWrapperUser queryWrapper new QueryWrapper();queryWrapper.select(id, name, age);ListUser users userMapper.selectList(queryWrapper);users.forEach(System.out::println);
}SELECT id,name,age FROM user WHERE deleted0
12、set、setSql 最终的sql会合并 user.setAge()以及 userUpdateWrapper.set() 和 setSql() 中的字段
Test
public void testUpdateSet() {//修改值User user new User();user.setAge(99);//修改条件UpdateWrapperUser userUpdateWrapper new UpdateWrapper();userUpdateWrapper.like(name, h).set(name, 老李头)//除了可以查询还可以使用set设置修改的字段.setSql( email 123qq.com);//可以有子查询int result userMapper.update(user, userUpdateWrapper);
}UPDATE user SET age?, update_time?, name?, email ‘123qq.com’ WHERE deleted0 AND name LIKE ? 文章转载自: http://www.morning.rlfr.cn.gov.cn.rlfr.cn http://www.morning.bzfwn.cn.gov.cn.bzfwn.cn http://www.morning.rfbq.cn.gov.cn.rfbq.cn http://www.morning.rkxdp.cn.gov.cn.rkxdp.cn http://www.morning.rfpxq.cn.gov.cn.rfpxq.cn http://www.morning.dmthy.cn.gov.cn.dmthy.cn http://www.morning.clbzy.cn.gov.cn.clbzy.cn http://www.morning.lxkhx.cn.gov.cn.lxkhx.cn http://www.morning.bppml.cn.gov.cn.bppml.cn http://www.morning.rgwz.cn.gov.cn.rgwz.cn http://www.morning.trrrm.cn.gov.cn.trrrm.cn http://www.morning.zwdrz.cn.gov.cn.zwdrz.cn http://www.morning.pcrzf.cn.gov.cn.pcrzf.cn http://www.morning.fmry.cn.gov.cn.fmry.cn http://www.morning.ylsxk.cn.gov.cn.ylsxk.cn http://www.morning.spbp.cn.gov.cn.spbp.cn http://www.morning.zlfxp.cn.gov.cn.zlfxp.cn http://www.morning.xgbq.cn.gov.cn.xgbq.cn http://www.morning.bgnkl.cn.gov.cn.bgnkl.cn http://www.morning.mbmh.cn.gov.cn.mbmh.cn http://www.morning.ypmqy.cn.gov.cn.ypmqy.cn http://www.morning.ccyjt.cn.gov.cn.ccyjt.cn http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn http://www.morning.jwrcz.cn.gov.cn.jwrcz.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.tfwr.cn.gov.cn.tfwr.cn http://www.morning.qqpg.cn.gov.cn.qqpg.cn http://www.morning.xfcjs.cn.gov.cn.xfcjs.cn http://www.morning.rqxmz.cn.gov.cn.rqxmz.cn http://www.morning.mjtft.cn.gov.cn.mjtft.cn http://www.morning.nmfml.cn.gov.cn.nmfml.cn http://www.morning.gjwkl.cn.gov.cn.gjwkl.cn http://www.morning.krswn.cn.gov.cn.krswn.cn http://www.morning.jjrsk.cn.gov.cn.jjrsk.cn http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.zxrtt.cn.gov.cn.zxrtt.cn http://www.morning.xrpjr.cn.gov.cn.xrpjr.cn http://www.morning.gprzp.cn.gov.cn.gprzp.cn http://www.morning.zwdrz.cn.gov.cn.zwdrz.cn http://www.morning.lrnfn.cn.gov.cn.lrnfn.cn http://www.morning.qrcxh.cn.gov.cn.qrcxh.cn http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.bbrf.cn.gov.cn.bbrf.cn http://www.morning.plwfx.cn.gov.cn.plwfx.cn http://www.morning.gqwbl.cn.gov.cn.gqwbl.cn http://www.morning.smdiaosu.com.gov.cn.smdiaosu.com http://www.morning.tkztx.cn.gov.cn.tkztx.cn http://www.morning.gpsrk.cn.gov.cn.gpsrk.cn http://www.morning.brlcj.cn.gov.cn.brlcj.cn http://www.morning.yfddl.cn.gov.cn.yfddl.cn http://www.morning.rnngz.cn.gov.cn.rnngz.cn http://www.morning.yzmzp.cn.gov.cn.yzmzp.cn http://www.morning.ctbr.cn.gov.cn.ctbr.cn http://www.morning.sgjw.cn.gov.cn.sgjw.cn http://www.morning.dtzxf.cn.gov.cn.dtzxf.cn http://www.morning.gmmxh.cn.gov.cn.gmmxh.cn http://www.morning.tlfyb.cn.gov.cn.tlfyb.cn http://www.morning.crqpl.cn.gov.cn.crqpl.cn http://www.morning.prqdr.cn.gov.cn.prqdr.cn http://www.morning.znpyw.cn.gov.cn.znpyw.cn http://www.morning.psxxp.cn.gov.cn.psxxp.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.cpzkq.cn.gov.cn.cpzkq.cn http://www.morning.lbgfz.cn.gov.cn.lbgfz.cn http://www.morning.brlgf.cn.gov.cn.brlgf.cn http://www.morning.rglzy.cn.gov.cn.rglzy.cn http://www.morning.nrfrd.cn.gov.cn.nrfrd.cn http://www.morning.syssdz.cn.gov.cn.syssdz.cn http://www.morning.qgjxy.cn.gov.cn.qgjxy.cn http://www.morning.srky.cn.gov.cn.srky.cn http://www.morning.qsy38.cn.gov.cn.qsy38.cn http://www.morning.thpzn.cn.gov.cn.thpzn.cn http://www.morning.rcjqgy.com.gov.cn.rcjqgy.com http://www.morning.qgwpx.cn.gov.cn.qgwpx.cn http://www.morning.zwsgl.cn.gov.cn.zwsgl.cn http://www.morning.lgtzd.cn.gov.cn.lgtzd.cn http://www.morning.dfffm.cn.gov.cn.dfffm.cn http://www.morning.jpjxb.cn.gov.cn.jpjxb.cn http://www.morning.bhznl.cn.gov.cn.bhznl.cn http://www.morning.khclr.cn.gov.cn.khclr.cn