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. js中字符串转数字的方法

    1.当字符串中是纯数字 例如:var s = '234'; /********** 字符串在运算操作中会被当做数字类型来处理 ***************/ s *= 1; /******* str ...

  2. OOP⑶

    /** * 学生类 * ctrl+o 查询本类的所有属性 和方法 */ public class Student { int age; // 年龄 String name; // 姓名 // 自己创建 ...

  3. vue-6-事件处理

    <div id="example-2"> <button v-on:click="greet">Greet</button> ...

  4. Xcode清理存储空间

    文章来自 枣泥布丁 http://www.cocoachina.com/ios/20170711/19814.html 请针对性的选择删除 移除 Xcode 运行安装 APP 产生的缓存文件(Deri ...

  5. ssm使用双数据源

    工作中需要接入其他公司业务系统的数据进行分析,于是接入它们的db. 使用双数据源配置感觉如下: database.sessionFactory.扫描器.事务管理器等双份. 听说如果两个数据源需要一起使 ...

  6. Problem A 还会用继承吗?

    定义一个Base类,包括1个int类型的属性,以及满足输出格式要求的构造函数.拷贝构造函数和析构函数. 定义Base类的子类Derived,包括1个int类型的属性, 以及满足输出格式要求的构造函数. ...

  7. C#正则表达式类Match和Group类的理解

    正则表达式可以看做一种有特定功能的小型编程语言,在一段文本中定位子字符串.利用正则表达式可以快速地分析大量的文本以找到特定的字符模式:提取.编辑.替换或删除文本子字符串:或将提取的字符串添加到集合.正 ...

  8. <Yarn> <Capacity Scheduler> <Source Code>

    Yarn capacity scheduler 首先要知道, [Attention: RM有两个组件,其中Scheduler完全就只是负责资源的分配:ApplicationsManager则负责接受a ...

  9. github咋用昂

    github-trend:https://github.com/trending github-usingway:https://zhuanlan.zhihu.com/p/41899093 githu ...

  10. Python 基础数据类型相互转换

    字符串,数字,列表 ,元祖,字典 化相互转化 1 Int 与 str 之间如何转化,转换的结果是什么?有没有条件?     #str(int型)可以转化为str 该过程没有条件     #字符串转化为 ...