场景

项目搭建专栏:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194

基础搭建:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/89407994

条件构造器介绍使用:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/89482201

实现

查看Condition的源码可知其继承自Wrapper方法,所以Wrapper的方法都可以使用。

它有一个获取实例的方法

/*** 获取实例*/public static Condition create() {return new Condition();}

编写测试方法:

/****条件构造器 Condition*/@Testpublic void testConditionOrderBy() {List<Employee> employeeList=employeeMapper.selectList(Condition.create().eq("gender",1).like("name", "霸").orderBy("age").last("desc limit 1,2")//.orderDesc(Arrays.asList(new String[] {"age"}))//.orderAsc(Arrays.asList(new String[] {"age"})));System.out.println("*******************"+employeeList);for (Employee employee : employeeList) {System.out.println(employee.getAge());}}

源码下载

https://download.csdn.net/download/badao_liumang_qizhi/11142337

Condition源码

/*** Copyright (c) 2011-2020, hubin (jobob@qq.com).* <p>* Licensed under the Apache License, Version 2.0 (the "License"); you may not* use this file except in compliance with the License. You may obtain a copy of* the License at* <p>* http://www.apache.org/licenses/LICENSE-2.0* <p>* Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT* WARRANTIES OR EntityWrapperS OF ANY KIND, either express or implied. See the* License for the specific language governing permissions and limitations under* the License.*/
package com.baomidou.mybatisplus.mapper;import com.baomidou.mybatisplus.toolkit.StringUtils;/*** <p>* 条件查询构造器* </p>** @author hubin Caratacus* @date 2016-11-7*/
@SuppressWarnings({"rawtypes", "serial"})
public class Condition extends Wrapper {/*** 构建一个Empty条件构造 避免传递参数使用null*/public static final Wrapper EMPTY = new Wrapper() {@Overridepublic String getSqlSegment() {return null;}};/*** 获取实例*/public static Condition create() {return new Condition();}/*** SQL 片段*/@Overridepublic String getSqlSegment() {if (SqlHelper.isEmptyOfWrapper(this)) {return null;}/** 无条件*/String sqlWhere = sql.toString();if (StringUtils.isEmpty(sqlWhere)) {return null;}/** 根据当前实体判断是否需要将WHERE替换成 AND 增加实体不为空但所有属性为空的情况*/return isWhere != null ? (isWhere ? sqlWhere : sqlWhere.replaceFirst("WHERE", AND_OR)) : sqlWhere.replaceFirst("WHERE", AND_OR);}/*** 构造一个空的Wrapper<T></>** @param <T>* @return*/public static <T> Wrapper<T> empty() {return (Wrapper<T>) EMPTY;}/*** 构造一个Wrapper<T></>** @param <T>* @return*/public static <T> EntityWrapper<T> wrapper() {return new EntityWrapper<>();}}

MyBatisPlus条件构造器Condition的用法相关推荐

  1. 第 4 章 MybatisPlus 条件构造器

    第 4 章 MybatisPlus 条件构造器 1.CRUD API 的思考 对于 BaseMapper 中基本 CRUD 方法的思考 继承了 BaseMapper 接口后,我们只能获得基本的 CRU ...

  2. MyBatisPlus条件构造器中last方法怎样使用

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

  3. Mybatis-Plus条件构造器学习and方法

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 Mybatis-Plus条件构造器学习and方法 一.代码 1.Controller 2.Service 3.效果 一.代码 1.Co ...

  4. Mybatis-Plus 条件构造器Wrapper常用方法

    Mybatis-Plus 条件构造器Wrapper常用方法 下面拼接的也就是sql语句里面where后面的: 1.eq 匹配与键值相等的数据 eq(键,值) 2.ne 匹配与键值不相等的数据 ne(键 ...

  5. MybatisPlus条件构造器说明以及selectPage方法

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

  6. MyBatisPlus条件构造器带条件排序方法orderBy、orderByDesc、orderByAsc使用

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

  7. MyBatisPlus条件构造器实现降序排序的两种方式

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

  8. MyBatisPlus条件构造器排序方法orderByDesc参数怎样构造

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

  9. MyBatisPlus条件构造器带条件删除delete使用

    场景 项目搭建专栏: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194 基础搭建: https://blog.csdn.net/B ...

最新文章

  1. free 命令查看linux的内存使用情况
  2. 【C语言】字符串函数strtok 按照指定字符串分割
  3. 一层循环时间复杂度_数据结构:二叉排序树的前/中/后序遍历(递归与循环两种版本)...
  4. react重新渲染菜单_React实现递归组件
  5. Mac 设置 NDK
  6. 2022年移动应用趋势洞察白皮书
  7. MVP 模式实例解析
  8. Chialisp是什么
  9. 前端的常见的面试试题
  10. ubuntu中pycharm无法输入汉字
  11. 自定义网页头部前面小图标
  12. 浏览器访问linux终端,使用浏览器访问 Linux 终端
  13. 【#9733;】选择好游戏认准这30个特质!
  14. 计算机英语怎么读音读,电脑的英文怎么发音按照标准的
  15. 猿创征文|pycharm中的翻译插件translation以及将其更换为百度翻译获取ID和密钥的详细步骤
  16. H5开发在微信浏览器上,加载时“白屏”问题
  17. 深度学习之选择GPU或CPU方法
  18. 虚拟主机服务器架设,云虚拟主机架设服务器
  19. model.generate返回句子大于1时出现<unk>的情况处理
  20. 标准分幅下的图幅号转换成经纬度坐标【原理+源代码】

热门文章

  1. php+防御+xss,PHP防御XSS攻击
  2. mybatis元素类型为 “resultMap“ 的内容必须匹配 “(constructor?,id *,result*,association报错解决
  3. html网页注册信息不完全时有警示_??使用Github做一个完全免费的个人网站(步骤很细)...
  4. windows11图文安装流程
  5. php 命名空间 create_function,PHP create_function()注入命令执行漏洞
  6. vue图片点击超链接_vue使用v-for实现hover点击效果
  7. 做了个EMMC分析治具
  8. EMMC型号格式查询
  9. 根据数据库表gengxin实体类_Python学习第四十八天记录打call:SQLALchemy操作MySQL关系型数据库...
  10. 西工大c语言noj100作业,西工大17秋《C语言程序设计》平时作业