example.or()
.andField1EqualTo(5)
.andField2IsNull(); example.or()
.andField3NotEqualTo(9)
.andField4IsNotNull(); List field5Values = new ArrayList();
field5Values.add(8);
field5Values.add(11);
field5Values.add(14);
field5Values.add(22); example.or()
.andField5In(field5Values); example.or()
.andField6Between(3, 7); 在上面的例子中, 动态生成的where子句是: where (field1 = 5 and field2 is null)
or (field3 <> 9 and field4 is not null)
or (field5 in (8, 11, 14, 22))
or (field6 between 3 and 7)
将会返回满足这些条件的记录结果.

example.setOrderByClause(“字段名 ASC”);添加升序排列条件,DESC为降序

example.setDistinct(false)去除重复,boolean型,true为选择不重复的记录。

criteria.andXxxIsNull添加字段xxx为null的条件

criteria.andXxxIsNotNull添加字段xxx不为null的条件

criteria.andXxxEqualTo(value)添加xxx字段等于value条件

criteria.andXxxNotEqualTo(value)添加xxx字段不等于value条件

criteria.andXxxGreaterThan(value)添加xxx字段大于value条件

criteria.andXxxGreaterThanOrEqualTo(value)添加xxx字段大于等于value条件

criteria.andXxxLessThan(value)添加xxx字段小于value条件

criteria.andXxxLessThanOrEqualTo(value)添加xxx字段小于等于value条件

criteria.andXxxIn(List<?>)添加xxx字段值在List<?>条件

criteria.andXxxNotIn(List<?>)添加xxx字段值不在List<?>条件

criteria.andXxxLike(“%”+value+”%”)添加xxx字段值为value的模糊查询条件

criteria.andXxxNotLike(“%”+value+”%”)添加xxx字段值不为value的模糊查询条件

criteria.andXxxBetween(value1,value2)添加xxx字段值在value1和value2之间条件

criteria.andXxxNotBetween(value1,value2)添加xxx字段值不在value1和value2之间条件

int countByExample(UserExample example) thorws SQLException按条件计数

int deleteByPrimaryKey(Integer id) thorws SQLException按主键删除

int deleteByExample(UserExample example) thorws SQLException按条件查询

String/Integer insert(User record) thorws SQLException插入数据(返回值为ID)

User selectByPrimaryKey(Integer id) thorws SQLException按主键查询

ListselectByExample(UserExample example) thorws SQLException按条件查询

ListselectByExampleWithBLOGs(UserExample example) thorws SQLException按条件查询(包括BLOB字段)。只有当数据表中的字段类型有为二进制的才会产生。

int updateByPrimaryKey(User record) thorws SQLException按主键更新

int updateByPrimaryKeySelective(User record) thorws SQLException按主键更新值不为null的字段

int updateByExample(User record, UserExample example) thorws SQLException按条件更新

int updateByExampleSelective(User record, UserExample example) thorws SQLException按条件更新值不为null的字段

原文:https://blog.csdn.net/biandous/article/details/65630783

方法说明example.setOrderByClause(“字段名 ASC”);添加升序排列条件,DESC为降序example.setDistinct(false)去除重复,boolean型,true为选择不重复的记录。criteria.andXxxIsNull添加字段xxx为null的条件criteria.andXxxIsNotNull添加字段xxx不为null的条件criteria.andXxxEqualTo(value)添加xxx字段等于value条件criteria.andXxxNotEqualTo(value)添加xxx字段不等于value条件criteria.andXxxGreaterThan(value)添加xxx字段大于value条件criteria.andXxxGreaterThanOrEqualTo(value)添加xxx字段大于等于value条件criteria.andXxxLessThan(value)添加xxx字段小于value条件criteria.andXxxLessThanOrEqualTo(value)添加xxx字段小于等于value条件criteria.andXxxIn(List<?>)添加xxx字段值在List<?>条件criteria.andXxxNotIn(List<?>)添加xxx字段值不在List<?>条件criteria.andXxxLike(“%”+value+”%”)添加xxx字段值为value的模糊查询条件criteria.andXxxNotLike(“%”+value+”%”)添加xxx字段值不为value的模糊查询条件criteria.andXxxBetween(value1,value2)添加xxx字段值在value1和value2之间条件criteria.andXxxNotBetween(value1,value2)添加xxx字段值不在value1和value2之间条件--------------------- 作者:biandous 来源:CSDN 原文:https://blog.csdn.net/biandous/article/details/65630783 版权声明:本文为博主原创文章,转载请附上博文链接!

Example [mybatis] 的用法的更多相关文章

  1. Mybatis基本用法--下

    Mybatis基本用法--下 第七部分 mybatis-spring-boot-starter 官网:http://www.mybatis.org/spring-boot-starter/mybati ...

  2. Mybatis基本用法--中

    Mybatis基本用法--中 第四部分 动态 SQL 动态 SQL 元素和使用 JSTL 或其他类似基于 XML 的文本处理器相似.MyBatis 采用功能强大的基于 OGNL 的表达式来消除其他元素 ...

  3. Mybatis基本用法--上

    Mybatis基本用法--上 本文只是为自己查漏补缺.全面的请看官方文档,支持中英文 原理参考:http://blog.csdn.net/luanlouis/article/details/40422 ...

  4. SpringBoot示例教程(一)MySQL与Mybatis基础用法

    示例需求 在Springboot2框架中,使用Mysql和Mybatis功能:1. Mysql+Datasource集成2. Mybatis+XML用法详解 数据库准备 采用了Oracle中的scot ...

  5. mybatis简单用法

    1.resultType 和 resultMap 引言: MyBatis中在查询进行select映射的时候,返回类型可以用resultType,也可以用resultMap,resultType是直接表 ...

  6. mybatis generator 用法

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

  7. mybatis like用法

    针对不同的数据库,like的用法是不一样的,现在具体来说一下 1,SQL SERVER SELECT * FROM user WHERE name like '%'+#{name}+'%' 2,Ora ...

  8. Mybatis基本用法

    搭建mybatis环境 1, 导入需要的jar包 mybatis-*.*.*.jar ojdbc6.jar 2, 配置mybatis的总配置文件: mybatis-config.xml 配置根标签 & ...

  9. MyBatis基础用法(一)

    <select id="getErrorTimes" resultType="Integer"> SELECT ErrorTimes FROM `e ...

随机推荐

  1. linux操作系统及命令Part 1

    1.关于linux系统的安装与流程     (1)下载Vmware workstation 与 linux系统(centos版本.redhat版本.Ubuntu版本...)镜像. (2)详细安装见有道 ...

  2. django+xadmin+echarts实现数据可视化

    使用xadmin后功能比较强大,在后台展示统计图表,这个需求真的有点烫手,最终实现效果如下图: xadmin后台与echarts完全融合遇到以下问题: 1.没有现成的数据model 2.获得指定时间段 ...

  3. this&super两个关键字的意义和用法

    "this",作为一个特殊的关键字,它的规则如下: 1.可以表示构造函数传递.this(a,b)表示调用另外一个构造函数.这里面的this就是一个特殊语法,不是变量,没有什么类型. ...

  4. bzoj2045

    题解: 莫比乌斯反演经典题目 直接套公式好了 代码: #include<bits/stdc++.h> using namespace std; ; typedef long long ll ...

  5. Python中os与sys模块的区别

    os与sys模块的官方解释如下: os: This module provides a portable way of using operating system dependent functio ...

  6. BootStrap字体图标不显示、下拉菜单不显示

    在W3CSchool学习BootStrap教程时遇到的问题…… 1.字体图标不能显示 上面是正常显示的样子,不能正常显示,因为缺少下面的字体图标样式文件 (1)在下载的Bootstrap包中将font ...

  7. Factory,工厂设计模式,C++描述

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  8. 十六. Python基础(16)--内置函数-2

    十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...

  9. 十二. Python基础(12)--生成器

    十二. Python基础(12)--生成器 1 ● 可迭代对象(iterable) An object capable of returning its members one at a time. ...

  10. CSS学习笔记-03- 过渡模块之前奏篇 a标签的伪类选择器

    CSS3 2D转换CSS3 3D转换CSS3 过渡CSS3 动画 CSS3 的四大金刚. 想要实现酷炫的视觉效果,上面4个是必须要掌握的.学习之前,先复习一下 视觉盛宴的前菜 :a标签的伪类选择器 铛 ...