
MyBatis-Plus
MyBatis-Plus
风流 少年
我走的很慢,但从不后退!Not designed!
展开
-
七:MyBatis-Plus 插件
ActiveRecord(简称AR)一直广受动态语言(PHP、Ruby等)的喜爱,而Java作为准静态语言,对于ActiveRecord往往只能感叹其优雅,所以我们也在AR道路上进行了一定的探索.Active Record主要要求不仅仅是实体要完成与表中的字段对应,还要自己能完成CRUD操作,负责把自己持久化。Active Record是一种领域模型Domain Model, 封装了部分业务逻辑。大概意思是实体自己能够完成持久化工作(即把dao层和entity层合并一起),也可以有部分逻辑(即有点像s原创 2020-10-09 21:50:37 · 1922 阅读 · 0 评论 -
六:MyBatis-Plus代码生成器
AutoGenerator 是 MyBatis-Plus 的代码生成器,通过 AutoGenerator 可以快速生成 Entity、Mapper、Mapper XML、Service、Controller 等各个模块的代码,极大的提升了开发效率。<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId>原创 2020-10-09 21:33:14 · 395 阅读 · 0 评论 -
五:MyBatis-Plus的Service封装
通用 Service CRUD 封装IService接口,进一步封装 CRUD 采用 get 查询单行 remove 删除 list 查询集合 page 分页 前缀命名方式区分 Mapper 层避免混淆,Save// 插入一条记录(选择字段,策略插入)boolean save(T entity);// 插入(批量)boolean saveBatch(Collection<T> entityList);// 插入(批量)boolean saveBatch(Collection<原创 2020-10-07 22:16:46 · 2487 阅读 · 1 评论 -
四:MyBatis-Plus 条件构造器
在写SQL where条件的时候我们经常使用 =、!=、>、>=、 <、<=、in、like、between and、not、is null 等来构造条件,在MyBatis-Plus中也可以通过方法来构造这些where条件。AbstractWrapperQueryWrapper(LambdaQueryWrapper)UpdateWrapper(LambdaUpdateWrapper)条件构造器对象// 构造select、delete语句where条件QueryWrap原创 2020-10-07 22:08:00 · 6850 阅读 · 1 评论 -
三:Mybatis-Plus通用CRUD
一:Create@SpringBootTestclass SpringbootMybatisplusApplicationTests { @Autowired private UserMapper userMapper; @Test public void testInsert() { User user = new User(); user.setUsername("gaozhanlong"); user.setPa原创 2020-10-04 22:00:49 · 804 阅读 · 0 评论 -
二:Mybatis-Plus 快速入门
一:建库、建表CREATE DATABASE mybatisplus DEFAULT CHARACTER SET utf8;CREATE TABLE `tbl_user` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `username` varchar(255) DEFAULT NULL COMMENT '用户名', `password` varchar(255) DEFAULT NULL COMMEN原创 2020-10-09 16:29:54 · 402 阅读 · 0 评论 -
一:MyBatis-Plus 简介
MyBatis 的劣势即使非常简单的单表SQL语句还要在xml中写sqlMyBatis自身功能不够丰富,例如没有自带分页插件MyBatis-Plus 简介https://mybatis.plus/https://github.com/baomidou/mybatis-plusGitHub中非常活跃,腾讯都在使用,并非炒作而是实至名归。public interface BaseMapper<T> extends Mapper<T> { /** *原创 2020-10-06 22:18:18 · 10700 阅读 · 3 评论