首页 > 其他分享 >JPA中使用limit

JPA中使用limit

时间:2023-08-29 12:31:42浏览次数:36  
标签:JPA paramType _. limit result 使用 query checkconte0

 

4.4.5. Limiting Query Results

You can limit the results of query methods by using the first or top keywords, which you can use interchangeably. You can append an optional numeric value to top or first to specify the maximum result size to be returned. If the number is left out, a result size of 1 is assumed. The following example shows how to limit the query size:

Example 18. Limiting the result size of a query with Top and First

User findFirstByOrderByLastnameAsc();

User findTopByOrderByAgeDesc();

Page<User> queryFirst10ByLastname(String lastname, Pageable pageable);

Slice<User> findTop3ByLastname(String lastname, Pageable pageable);

List<User> findFirst10ByLastname(String lastname, Sort sort);

List<User> findTop10ByLastname(String lastname, Pageable pageable);

The limiting expressions also support the Distinct keyword for datastores that support distinct queries. Also, for the queries that limit the result set to one instance, wrapping the result into with the Optional keyword is supported.

If pagination or slicing is applied to a limiting query pagination (and the calculation of the number of available pages), it is applied within the limited result.

 

Limiting the results in combination with dynamic sorting by using a Sort parameter lets you express query methods for the 'K' smallest as well as for the 'K' biggest elements.

https://docs.spring.io/spring-data/jpa/docs/2.7.15/reference/html/#repositories.limit-query-result

 

JPA中使用limit_limit

 

2023-08-23 09:38:19.597 [main] INFO  o.h.hql.internal.QueryTranslatorFactoryInitiator - HHH000397: Using ASTQueryTranslatorFactory
Hibernate: 
    select
        checkconte0_.id as id1_1_,
        checkconte0_.checkResult as checkRes2_1_,
        checkconte0_.createTime as createTi3_1_,
        checkconte0_.fileMd5 as fileMd4_1_,
        checkconte0_.fileName as fileName5_1_,
        checkconte0_.paramType as paramTyp6_1_,
        checkconte0_.requestParam as requestP7_1_,
        checkconte0_.resultJson as resultJs8_1_,
        checkconte0_.transferResult as transfer9_1_ 
    from
        CheckContentEntity checkconte0_ 
    where
        checkconte0_.fileName=? 
        and checkconte0_.paramType=? limit ?
CheckContentEntity(id=3117759, requestParam=https://s.cn.bing.net/th?id=OHR.SkogafossWaterfall_ZH-CN4763253095_1920x1080.webp&qlt=50, paramType=2, fileName=image.jpg, fileMd5=571903dd289ff0d6fb93bbb399cb9572, checkResult=1, resultJson={"conclusion":"合规","log_id":16919943910398412,"isHitMd5":false,"conclusionType":1}, createTime=2023-08-14T14:26:34, transferResult=null)
Hibernate: 
    select
        checkconte0_.id as id1_1_,
        checkconte0_.checkResult as checkRes2_1_,
        checkconte0_.createTime as createTi3_1_,
        checkconte0_.fileMd5 as fileMd4_1_,
        checkconte0_.fileName as fileName5_1_,
        checkconte0_.paramType as paramTyp6_1_,
        checkconte0_.requestParam as requestP7_1_,
        checkconte0_.resultJson as resultJs8_1_,
        checkconte0_.transferResult as transfer9_1_ 
    from
        CheckContentEntity checkconte0_ 
    where
        checkconte0_.requestParam=? 
        and checkconte0_.paramType=? limit ?
null

 



标签:JPA,paramType,_.,limit,result,使用,query,checkconte0
From: https://blog.51cto.com/u_15147537/7275067

相关文章

  • redis数据类型和使用命令
    目录一通用命令1.1通用命令1.2数据结构和内部编码1.3单线程架构,二字符串类型2.1字符串键值结构2.2常用命令三hash类型3.1哈希值结构3.2常用命令3.3hashvsstring四列表类型4.1列表特点常用命令五集合类型5.1特点5.2常用命令六有序集合类型6.1特点6.2常用命令......
  • 原来笔记本一直插着电源使用比较好 工作原理3张图秒懂
    热搜内容提到:原来笔记本一直插着电源使用比较好!笔记本电脑在充满电后使用,电源适配器将继续为电脑供电,而充满电的内置电池则不会继续工作,并不会出现一边充电、一边放电的情况。据了解,笔记本电脑里的锂电池没有记忆效应,而且正规厂家生产的锂电池都有相当完善的BMS(电池管理系统),......
  • JTS-IntersectionMatrix 使用说明
    参考:https://blog.csdn.net/weixin_40294332/article/details/124124928参考2:https://vimsky.com/examples/detail/java-method-com.vividsolutions.jts.geom.IntersectionMatrix.set.html......
  • 【Element】el-dialog 内使用 el-image 并添加 preview-src-list 预览,拖拽导致图片预
    现象el-dialog内使用el-image并添加preview-src-list预览,拖拽导致图片预览不完整<el-dialogwidth="500"v-model="visible":title="activeProp?.name"@close="handleClose":draggable="true"//可拖拽......
  • 【个人杂谈】假如我是一个前端工程师,我该如何在日常的学习过程中使用费曼学习法?
    什么是费曼学习法?费曼学习法是一种学习方法,它由诺贝尔物理学奖得主理查德·费曼(美籍犹太裔物理学家,加州理工学院物理学教授,1965年诺贝尔物理奖得主)提出。该方法的核心思想是通过将所学的知识以简单明了的方式解释给别人,来加深自己对知识的理解和掌握。具体来说,费曼学习法包括以......
  • Boost库的安装与使用
    一、下载Boost库下载地址:https://www.boost.org/users/download/二、编译Boost库cdboost_1_72_0./bootstrap.sh--with-python=python2.7#修改Python2.7的路径,改为:/usr/include/python2.7vimproject-config.jam#将boost库相关文件安装至/usr/localsudo./b2--prefix=/usr......
  • 安装python3.5并在QT中配置使用
    一、安装32位的python3.5及各种库链接:https://pan.baidu.com/s/1q94_Vo3XDhfZ_hmssPjz6w提取码:zotf先在dos环境下输入python,如果显示版本则表示python安装成功,安装库文件的时候,在dos环境下进入whl文件所在的目录,然后使用pipinstall***-whl。如果提示pip版本过低,则按照提示更新pip......
  • Linux系统使用中常见的问题
    文章目录1、安装某个软件时提示:现在没有可用的软件包但是它被其他软件占用了2、安装vim3、安装搜狗输入法4、vim全局替换5、linux环境变量的设置6、运行c/c++程序7、linux中g++支持C++11的方法(在头文件中包含)8、安装git1、安装某个软件时提示:现在没有可用的软件包但是它被其他软......
  • C# List.Reverse 方法使用
    此方法用于Array.Reverse反转元素的顺序usingSystem;usingSystem.Collections.Generic;publicclassExample{publicstaticvoidMain(){List<string>dinosaurs=newList<string>();dinosaurs.Add("Pachycephalosaurus")......
  • EVE-NG 客户端使用MobaXterm
    EVE-NG客户端使用MobaXterm打开注册表编辑器进入HKEY_CLASSES_ROOT\telnet\shell\open\command将默认值改为"你MobaXterm的路径""-url"%l就这样......