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. Win10系列:JavaScript动画2

    "重新定位"动画也是Windows动画库中的动画效果."重新定位"动画的动画效果是指一个或一组元素移动到新的位置时,这些元素不是突然出现在新的位置,而是从一个位 ...

  2. java IO实例

    import java.io.*; /** * Created by CLY on 2017/7/23. */ public class Main { public static void main( ...

  3. 《Python》IO模型

    一.IO模型介绍 为了更好地了解IO模型,我们需要事先回顾下: 同步:一件事情做完再做另一件事情 异步:同时做多件事情 阻塞:sleep.input.join.shutdown.get.acquire ...

  4. UIScrollview的 约束 contentsize contentoffset contentinset layoutsubviews needlayout等影响布局的属性

    很久没有写视图布局,最近发现写布局很不顺手,总结一下在处理UIScrollview的时候种种注意事项: 1. self.automaticallyAdjustsScrollViewInsets = N ...

  5. Cracking The Coding Interview 2.2

    #include <iostream> #include <string> using namespace std; class linklist { private: cla ...

  6. 深入理解java虚拟机---Class文件(二十)

    无符号数.表 当实现了不同语言的编译器,比如jython,jruby等等,那么就可以利用这些语言编写代码,通过各自的编译器编译成符合jvm规范的字节码文件,就可以利用jvm来执行了. Class文件在 ...

  7. 深入理解java虚拟机---内存分配策略(十三)

    转载请注明原文地址:https://blog.csdn.net/initphp/article/details/30487407 Java内存分配策略 使用的ParNew+Serial Old收集器组 ...

  8. SQL-24 获取所有非manager员工当前的薪水情况,给出dept_no、emp_no以及salary ,当前表示to_date='9999-01-01'

    题目描述 获取所有非manager员工当前的薪水情况,给出dept_no.emp_no以及salary ,当前表示to_date='9999-01-01'CREATE TABLE `dept_emp` ...

  9. poj1062(分区间迪杰斯特拉,内含测试数据,一直wa的同学可以进来看看)

    昂贵的聘礼 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 54946   Accepted: 16518 Descripti ...

  10. <Spark><Advanced Programming>

    Introduction 介绍两种共享变量的方式: accumulators:聚集信息 broadcast variables:高效地分布large values 介绍对高setup costs任务的 ...