0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

mybatis plus的常规用法

科技绿洲 来源:Java技术指北 作者:Java技术指北 2023-09-25 15:06 次阅读

上篇文章我们介绍过通过 Mybatis Plus 进行增删改查,如下这段代码:

/**
 * 根据id修改
 * UPDATE user SET user_name=?, user_age=? WHERE (id = ?)
 */
@Test
public void testudpateById(){
    User user = new User();
    user.setUserAge("25");
    user.setUserName("test update");
    UpdateWrapper updateWrapper = new UpdateWrapper();
    updateWrapper.eq("id","3");
    int num = userMapper.update(user, updateWrapper);
    System.out.println("修改的记录数为:"+num);
}
     
/**
 * 查询指定记录
 * SELECT id,user_name,user_age FROM user WHERE (user_name = ?)
 */
@Test
public void testSelectWrapper(){
    QueryWrapper wrapper = new QueryWrapper();
    wrapper.eq("user_name","IT可乐");
    List< User > users = userMapper.selectList(wrapper);
    users.forEach(x- > System.out.println(x.getId()+"-"+x.getUserName()+"-"+x.getUserAge()));
}

上面两个方法分别是根据id修改表记录,和根据user_name查询记录。构造的条件使用了 UpdateWrapper 和 QueryWrapper ,那么这是什么呢?其实 mybatis plus 通过条件构造器可以组成复杂的SQL语句。本篇博客我们将详细介绍。

1、Wrapper

Mybatis Plus 提供的几种条件构造器,关系如下:

图片

我们主要通过 QueryWrapper 和 UpdateWrapper 进行条件构造,这两个和 LambdaQueryWrapper、LambdaUpdateWrapper 差不多是等价的,只不过后者采用了 JDK1.8 提供的lambda 语法,使用起来更简洁。

2、语法详情总结

关于条件构造器的各个用法介绍,可以参考官网:https://mp.baomidou.com/guide/wrapper.html#abstractwrapper

这里我们做一下总结:

方法名说明用法实例等价SQL
官网地址https://mp.baomidou.com/guide/wrapper.html#abstractwrapper----::----:
allEq(Map params)全部等于map.put("id","3");map.put("user_name","IT可乐");allEq(map)user_name = "IT可乐" AND id = 3
eq(R column, Object val)等于 =eq("id","3")id = 3
ne(R column, Object val)不等于 <>ne("id", "3")id <> 3
gt(R column, Object val)大于 >gt("user_age","18")user_age > 18
ge(R column, Object val)大于等于 >=ge("user_age","18")user_age >= 18
lt(R column, Object val)小于 <lt("user_age","18")user_age < 18
le(R column, Object val)小于等于 <=le("user_age","18")user_age <= 18
between(R column, Object val1, Object val2)BETWEEN 值1 AND 值2between("user_age","18","25")user_age BETWEEN 18 AND 25
notBetween(R column, Object val1, Object val2)NOT BETWEEN 值1 AND 值2notBetween("user_age","18","25")user_age NOT BETWEEN 18 AND 25
like(R column, Object val)LIKE '%值%'like("user_name","可乐")like ‘%可乐%’
notLike(R column, Object val)NOT LIKE '%值%'notLike("user_name","可乐")not like ‘%可乐%’
likeLeft(R column, Object val)LIKE '%值'likeLeft("user_name","可乐")like ‘%可乐’
likeRight(R column, Object val)LIKE '值%'likeRight("user_name","可乐")like ‘可乐%’
isNull(R column)字段 IS NULLisNull("user_name")user_name IS NULL
isNotNull(R column)字段 IS NOT NULLisNotNull("user_name")user_name IS NOT NULL
in(R column, Collection value)字段 IN (value.get(0), value.get(1), ...)in("user_age",{1,2,3})user_age IN (?,?,?)
notIn(R column, Collection value)字段 NOT IN (value.get(0), value.get(1), ...)notIn("user_age",{1,2,3})user_age NOT IN (?,?,?)
inSql(R column, String inValue)字段 IN ( sql语句 )inSql("id","select id from user")id IN (select id from user)
notInSql(R column, String inValue)字段 NOT IN ( sql语句 )notInSql("id","select id from user where id > 2")id NOT IN (select id from user where id > 2
groupBy(R... columns)分组:GROUP BY 字段, ...groupBy("id","user_age")GROUP BY id,user_age
orderByAsc(R... columns)排序:ORDER BY 字段, ... ASCorderByAsc("id","user_age")ORDER BY id ASC,user_age ASC
orderByDesc(R... columns)排序:ORDER BY 字段, ... DESCorderByDesc("id","user_age")ORDER BY id DESC,user_age DESC
orderBy(boolean condition, boolean isAsc, R... columns)ORDER BY 字段, ...orderBy(true,true,"id","user_age")ORDER BY id ASC,user_age ASC
having(String sqlHaving, Object... params)HAVING ( sql语句 )having("sum(user_age)>{0}","25")HAVING sum(user_age)>25
or()拼接 OReq("id",1).or().eq("user_age",25)id = 1 OR user_age = 25
and(Consumerconsumer)AND 嵌套and(i->i.eq("id",1).ne("user_age",18))id = 1 AND user_age <> 25
nested(Consumerconsumer)正常嵌套 不带 AND 或者 ORnested(i->i.eq("id",1).ne("user_age",18))id = 1 AND user_age <> 25
apply(String applySql, Object... params)拼接 sql(不会有SQL注入风险)apply("user_age>{0}","25 or 1=1")user_age >'25 or 1=1'
last(String lastSql)拼接到 sql 的最后,多次调用以最后一次为准(有sql注入的风险)last("limit 1")limit 1
exists(String existsSql)拼接 EXISTS ( sql语句 )exists("select id from user where user_age = 1")EXISTS (select id from user where user_age = 1)
notExists(String notExistsSql)拼接 NOT EXISTS ( sql语句 )notExists("select id from user where user_age = 1")NOT EXISTS (select id from user where user_age = 1)

3、语法详情演示

对于上表出现的每个语法,这里通过代码展示出来。

更多可以参考地址:https://github.com/YSOcean/mybatisplusstudy.git

package com.ys.mybatisplusstudy;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ys.mybatisplusstudy.entry.User;
import com.ys.mybatisplusstudy.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@SpringBootTest
public class WrapperTest {
    @Autowired
    private UserMapper userMapper;
 
 
    /**
     * 新增一条记录
     */
    @Test
    public void testInsert(){
        User user = new User();
        user.setId(4L);
        user.setUserName("test insert");
        user.setUserAge("1");
        int insert = userMapper.insert(user);
        System.out.println("影响记录数:"+insert);
    }
 
    /**
     * allEq 全部等于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name = ? AND id = ?)
     */
    @Test
    public void testAllEq(){
        QueryWrapper queryWrapper = new QueryWrapper();
        Map map = new HashMap<  >();
        map.put("id","3");
        map.put("user_name","IT可乐");
        queryWrapper.allEq(map);
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * eq 等于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (id = ?)
     */
    @Test
    public void testEq(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id","3");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * ne 不等于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (id <  > ?)
     */
    @Test
    public void testNe(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.ne("id","3");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * gt 大于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age > ?)
     */
    @Test
    public void testGt(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.gt("user_age","18");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * ge 大于等于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age >= ?)
     */
    @Test
    public void testGe(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.ge("user_age","18");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * lt 小于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age < ?)
     */
    @Test
    public void testLt(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.lt("user_age","18");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * le 小于等于
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age <= ?)
     */
    @Test
    public void testLe(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.le("user_age","18");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * between 值1和值2之间,两边临界值都包含
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age BETWEEN ? AND ?)
     */
    @Test
    public void testBetween(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.between("user_age","18","25");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * notBetween 不在值1和值2之间,两边临界值都包含
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age NOT BETWEEN ? AND ?)
     */
    @Test
    public void testNoBetween(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.notBetween("user_age","18","25");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * like 模糊查询,会在参数左右两边加上 %
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name LIKE ?)
     */
    @Test
    public void testLike(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like("user_name","可乐");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * notLike NOT LIKE ‘%parameter%’
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name NOT LIKE ?)
     */
    @Test
    public void testNotLike(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.notLike("user_name","可乐");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * likeLeft LIKE ‘%parameter’
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name LIKE '%parameter')
     */
    @Test
    public void testLikeLeft(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.likeLeft("user_name","可乐");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * likeRight LIKE ‘parameter%’
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name LIKE 'parameter%')
     */
    @Test
    public void testLikeRight(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.likeRight("user_name","可乐");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
    /**
     * isNull 判断字段为null
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name IS NULL)
     */
    @Test
    public void testIsNull(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.isNull("user_name");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * isNotNull 判断字段不为null
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_name IS NOT NULL)
     */
    @Test
    public void testIsNotNull(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.isNotNull("user_name");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * in 范围定值查询
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age IN (?,?,?))
     */
    @Test
    public void testIn(){
        QueryWrapper queryWrapper = new QueryWrapper();
        List< Integer > queryList = new ArrayList<  >();
        queryList.add(18);
        queryList.add(1);
        queryList.add(25);
        queryWrapper.in("user_age",queryList);
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * notIn
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age IN (?,?,?))
     */
    @Test
    public void testNotIn(){
        QueryWrapper queryWrapper = new QueryWrapper();
        List< Integer > queryList = new ArrayList<  >();
        queryList.add(18);
        queryList.add(1);
        queryList.add(25);
        queryWrapper.notIn("user_age",queryList);
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * inSql
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (id IN (select id from user))
     */
    @Test
    public void testInSql(){
        QueryWrapper queryWrapper = new QueryWrapper();
        //查询所有数据
        queryWrapper.inSql("id","select id from user");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * notInSql
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (id NOT IN (select id from user where id > 2))
     */
    @Test
    public void testNotInSql(){
        QueryWrapper queryWrapper = new QueryWrapper();
        //查询所有数据
        queryWrapper.notInSql("id","select id from user where id > 2");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * groupBy 分组
     * 下面SQL有个问题,在MySQL8.0版本中,是可以执行下面SQL语句的,select user_name并没有出现在group by 语句中
     * 实例SQL:SELECT id,user_name,user_age FROM user GROUP BY id,user_age
     */
    @Test
    public void testGroupBy(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.groupBy("id","user_age");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * orderByAsc 升序
     * 实例SQL:SELECT id,user_name,user_age FROM user ORDER BY id ASC,user_age ASC
     */
    @Test
    public void testOrderByAsc(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByAsc("id","user_age");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * orderByDesc 降序
     * 实例SQL:SELECT id,user_name,user_age FROM user ORDER BY id DESC,user_age DESC
     */
    @Test
    public void testOrderByDesc(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("id","user_age");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * orderBy 指定顺序排序
     * 实例SQL:SELECT id,user_name,user_age FROM user ORDER BY id ASC,user_age ASC
     */
    @Test
    public void testOrderBy(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderBy(true,true,"id","user_age");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * having
     * 实例SQL:SELECT id,user_name,user_age FROM user GROUP BY id,user_age HAVING sum(user_age) >?
     */
    @Test
    public void testHaving(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.groupBy("id","user_age");
        queryWrapper.having("sum(user_age) >{0}","25");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * having
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (id = ? OR user_age = ?)
     */
    @Test
    public void testOr(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",1);
        queryWrapper.or();
        queryWrapper.eq("user_age",25);
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * and
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE ((id = ? AND user_age <  > ?))
     */
    @Test
    public void testAnd(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.and(i- >i.eq("id",1).ne("user_age",18));
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * nested
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE ((id = ? AND user_age <  > ?))
     */
    @Test
    public void testNested(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.nested(i- >i.eq("id",1).ne("user_age",18));
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * apply
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (user_age >?)
     */
    @Test
    public void testApplyd(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.apply("user_age >{0}","25 or 1=1");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * last
     * 实例SQL:SELECT id,user_name,user_age FROM user limit 1
     */
    @Test
    public void testLast(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.last("limit 1 ");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
 
    /**
     * exists
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (EXISTS (select id from user where user_age = 1))
     */
    @Test
    public void testExists(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.exists("select id from user where user_age = 1");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
 
 
    /**
     * notExists
     * 实例SQL:SELECT id,user_name,user_age FROM user WHERE (EXISTS (select id from user where user_age = 1))
     */
    @Test
    public void testNotExists(){
        QueryWrapper< User > queryWrapper = new QueryWrapper<  >();
        queryWrapper.notExists("select id from user where user_age = 1");
        List< User > list = userMapper.selectList(queryWrapper);
        System.out.println(list);
    }
}

4、LambdaQueryWrapper和LambdaUpdateWrapper(推荐

LambdaQueryWrapper 和 LambdaUpdateWrapper 这是相对于 QueryWrapper 及 UpdateWrapper 的 Lmbda 语法实现方式。

分别通过如下两种方式获取:

//两种方式        
LambdaQueryWrapper queryLambda = new QueryWrapper().lambda();
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<  >();

//两种方式
LambdaUpdateWrapper updateLambda = new UpdateWrapper().lambda();
LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper();

注意:获取LambdaQueryWrapper 和 LambdaUpdateWrapper 对象时,为了使用lambda语法,要使用泛型。

下面我演示几个实例:

/**
 * LambdaQueryWrapper
 * SQL实例:SELECT id,user_name,user_age FROM user WHERE (id = ? AND user_age <  > ?)
 */
@Test
public void testLambdaQueryWrapper(){
    LambdaQueryWrapper< User > queryLambda = new LambdaQueryWrapper<  >();
    queryLambda.eq(User::getId,"1").ne(User::getUserAge,25);
    List< User > users = userMapper.selectList(queryLambda);
    System.out.println(users);
 
}
 
/**
 * LambdaQueryWrapper
 * SQL实例:UPDATE user SET user_name=? WHERE (user_name = ?)
 */
@Test
public void testLambdaUpdateWrapper(){
    User user = new User();
    user.setUserName("LambdaUpdateWrapper");
    LambdaUpdateWrapper< User > userLambdaUpdateWrapper = new LambdaUpdateWrapper<  >();
    userLambdaUpdateWrapper.eq(User::getUserName,"IT可乐");
    userMapper.update(user,userLambdaUpdateWrapper);
 
}

5、总结

对于mybatis plus 中的四种条件构造器,我们就到此结束了,大家可以按照我的实例敲一遍代码,基本上就没啥问题了。

有没有发现使用 Lamba 语法很爽,语法简洁,另外有个优点是,使用QueryWrapper或者UpdateWrapper时,对于条件的某个列,我们是写的字符串配置,比如 QueryWrapper.eq("id",1);这里的id是数据库表的列名,很有可能我们会写错,但是通过lambda 的方式,LambdaQueryWrapper.eq(User::getId,1),这样就不会有写错的可能了。所以推荐大家使用Lambda 的方式。

至此,mybatis plus 的常规用法就全部介绍结束了,当然,事情还远没有结束,为了让大家用的更爽,后续将给大家介绍一些高阶玩法。

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 代码
    +关注

    关注

    30

    文章

    4556

    浏览量

    66807
  • 语法
    +关注

    关注

    0

    文章

    40

    浏览量

    9669
  • SQL语句
    +关注

    关注

    0

    文章

    18

    浏览量

    6989
  • Lambda
    +关注

    关注

    0

    文章

    26

    浏览量

    9775
  • mybatis
    +关注

    关注

    0

    文章

    57

    浏览量

    6646
收藏 人收藏

    评论

    相关推荐

    一文了解MyBatis的查询原理

    本文通过MyBatis一个低版本的bug(3.4.5之前的版本)入手,分析MyBatis的一次完整的查询流程,从配置文件的解析到一个查询的完整执行过程详细解读MyBatis的一次查询流程,通过本文
    的头像 发表于 10-10 11:42 1083次阅读

    Mybatis的内部设计介绍

    Mybatis源码分析-整体设计(一)
    发表于 06-06 09:43

    MyBatis的整合

    SpringBoot-15-之整合MyBatis-注解篇+分页
    发表于 10-28 08:09

    Mybatis是什么

    Mybatis第一讲
    发表于 06-04 15:33

    KEIL断点调试窗口的常规用法有哪些

    程序运行过程中的数据是怎么修改的?在哪里修改的?KEIL断点调试窗口的常规用法有哪些?
    发表于 02-17 06:32

    FreeRTOS plus用法实例讲解

    本文档的主要内容详细介绍的是FreeRTOS plus用法实例讲解。
    发表于 11-07 17:31 19次下载
    FreeRTOS <b class='flag-5'>plus</b>的<b class='flag-5'>用法</b>实例讲解

    一篇让你熟练掌握 MyBatis-Plus

    MyBatis-plus 是一款 Mybatis 增强工具,用于简化开发,提高效率。下文使用缩写 mp来简化表示 MyBatis-plus,本文主要介绍 mp 搭配 Spring Boot
    的头像 发表于 06-01 09:30 2367次阅读
    一篇让你熟练掌握 <b class='flag-5'>MyBatis-Plus</b>!

    Mybatis-Plus Mybatis增强工具包

    ./oschina_soft/gitee-mybatis-plus.zip
    发表于 06-13 11:34 1次下载
    <b class='flag-5'>Mybatis-Plus</b> <b class='flag-5'>Mybatis</b>增强工具包

    MyBatis-Plus的使用与测试

    本文主要介绍mybatis-plus这款插件,针对springboot用户。包括引入,配置,使用,以及扩展等常用的方面做一个汇总整理,尽量包含大家常用的场景内容。
    的头像 发表于 08-22 11:56 965次阅读

    MyBatis-Plus为什么不支持联表

    MyBatis Plus Join`一款专门解决MyBatis Plus 关联查询问题的扩展框架,他并不一款全新的框架,而是基于`MyBatis
    的头像 发表于 02-28 15:19 1765次阅读
    <b class='flag-5'>MyBatis-Plus</b>为什么不支持联表

    介绍一款基于Mybatis-Plus的代码自助生成器

    在基于Mybatis的开发模式中,很多开发者还会选择Mybatis-Plus来辅助功能开发,以此提高开发的效率。
    的头像 发表于 05-23 14:16 854次阅读
    介绍一款基于<b class='flag-5'>Mybatis-Plus</b>的代码自助生成器

    如何调优MyBatis 25倍性能

    最近在压测一批接口,发现接口处理速度慢的有点超出预期,感觉很奇怪,后面定位发现是数据库批量保存这块很慢。 这个项目用的是 mybatis-plus,批量保存直接用的是 mybatis-plus 提供的 saveBatch。 我点进去看了下源码,感觉有点不太对劲
    的头像 发表于 05-30 09:56 385次阅读
    如何调优<b class='flag-5'>MyBatis</b> 25倍性能

    你还在手写join联表查询?MyBatis-Plus这样写太香了!

    众所周知,mybatis plus 封装的 mapper 不支持 join,如果需要支持就必须自己去实现。但是对于大部分的业务场景来说,都需要多表 join,要不然就没必要采用关系型数据库了。
    的头像 发表于 07-07 10:19 852次阅读
    你还在手写join联表查询?<b class='flag-5'>MyBatis-Plus</b>这样写太香了!

    mybatis和mybatisplus的区别

    MyBatisMyBatis Plus是两个非常受欢迎的Java持久层框架。这两个框架在设计和功能上有一些区别,下面我将详细介绍它们之间的差异以及各自的特点。 设计理念与目标: MyBati
    的头像 发表于 12-03 11:53 1328次阅读

    mybatis中$和井号区别

    MyBatis是一个开源的Java持久层框架,它提供了许多强大的功能用于简化数据库操作。在MyBatis中,我们可以使用两种方式来动态生成SQL语句:$和#。 和#都可以用来替换SQL语句中的参数
    的头像 发表于 12-03 14:53 527次阅读