mybatis QueryWrapper的条件构造之apply、last、select解析
作者:Neic 时间:2022-02-12 17:32:51
QueryWrapper条件构造之apply、last、select
场景: 查询数据库限制条数时
mysql上的limit使用
QueryWrapper needSyn = new QueryWrapper();
needSyn.ge("ModifyDate",lmtSynRec.getLatestDate());
needSyn.last("limit 200");
List<CusCarInfo> needData = cusCarInfoMapper.selectList(needSyn);
如果是oracle则可以用apply
needSyn.apply("rownum < {0}" , 200);
如果是sqlserver
建议自己写sql查询语句
<select id="getSynList" resultType="com.xmeport.project.model.entity.CusCarInfo">
select top ${top} * from CUS_CAR_INFO t where t.ModifyDate > cast(#{latestDate} as datetime) orderBy
t.ModifyDate asc
</select>
List<CusCarInfo> getSynList(int top, Date latestDate);
或者使用QueryWrapper的select
QueryWrapper<CusCarInfo> wrapper = new QueryWrapper();
wrapper.select("top 200 *");
return this.list(wrapper);
来源:https://blog.csdn.net/u012078155/article/details/106760123
标签:QueryWrapper,条件构造,apply,last,select
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java寻找迷宫路径的简单实现示例
2021-07-06 13:17:50
JAVA8之函数式编程Function接口用法
2022-01-04 04:03:04
![](https://img.aspxhome.com/file/2023/6/63276_0s.jpg)
Spring2.5.6开发环境搭建图文教程
2023-07-28 18:01:02
![](https://img.aspxhome.com/file/2023/4/74764_0s.jpg)
JAVA面试题 简谈你对synchronized关键字的理解
2022-09-17 17:06:05
IDEA如何自动生成serialVersionUID的设置
2023-08-09 04:00:33
![](https://img.aspxhome.com/file/2023/1/57701_0s.png)
图文详解Maven工程打jar包的N种方式
2022-12-12 21:36:23
![](https://img.aspxhome.com/file/2023/9/60359_0s.png)
Java超详细分析泛型与通配符
2023-07-28 08:34:26
![](https://img.aspxhome.com/file/2023/2/60592_0s.jpg)
解析Java线程同步锁的选择方法
2023-02-08 11:02:32
vscode+platformIO开发stm32f4的实现
2023-11-02 16:43:37
![](https://img.aspxhome.com/file/2023/9/105169_0s.png)
Java守护线程实例详解_动力节点Java学院整理
2023-03-29 08:14:30
![](https://img.aspxhome.com/file/2023/5/60175_0s.png)
myBatis实现三 级嵌套复杂对象的赋值问题
2023-11-23 06:42:26
详解Kotlin中的面向对象(一)
2023-08-17 12:57:38
SpringBoot深入探究@Conditional条件装配的使用
2021-08-18 00:06:53
![](https://img.aspxhome.com/file/2023/2/61792_0s.png)
Android完美实现平滑过渡的ViewPager广告条
2023-10-01 13:05:31
![](https://img.aspxhome.com/file/2023/2/87272_0s.jpg)
MyBatis字段名和属性名不一致的解决方法
2022-12-15 18:15:22
C#实现系统休眠或静止休眠的方法
2023-12-19 01:55:29
java高并发ScheduledThreadPoolExecutor与Timer区别
2023-08-11 03:08:29
SpringCloud开发课程查询功能
2022-04-21 14:22:46
![](https://img.aspxhome.com/file/2023/4/64134_0s.png)
log4j2日志异步打印(实例讲解)
2023-11-12 09:02:13
Android缓存机制——LruCache的详解
2023-07-30 07:26:34