当前位置: 首页 > news >正文

【Spring Data JPA】JPA 常用查询函数

文章目录

    • 前言
    • 函数查询表格


前言

函数查询的表格参考了官网的 2.7.3 版本的文档,JPA 的这种函数式查询方法改动不大,如果想知道更多的复杂查询,可以参考这篇文章
【Spring Data JPA】基于 JpaRepository 增删改查

官方文档地址
Spring Data JPA 2.7.3官方文档


函数查询表格

关键字关键字意思函数写法SQL 写法
Distinctdistinct 去重findDistinctByLastnameAndFirstnameselect distinct …​ where x.lastname = ?1 and x.firstname = ?2
Andand 关联findByLastnameAndFirstname… where x.lastname = ?1 and x.firstname = ?2
Oror 或者findByLastnameOrFirstname… where x.lastname = ?1 or x.firstname = ?2
Isis 是(与Equals一样)findByFirstname
findByFirstnameIs
… where x.firstname = ?1
Equals等于findByFirstname
findByFirstnameEquals
… where x.firstname = ?1
Betweenbetween 之间findByStartDateBetween… where x.startDate between ?1 and ?2
LessThanlessThan 小于(<)findByAgeLessThan… where x.age < ?1
LessThanEquallessThanEqual 小于等于(<=)findByAgeLessThanEqual… where x.age <= ?1
GreaterThangreaterThan 大于(>)findByAgeGreaterThan… where x.age > ?1
GreaterThanEqualgreaterThan 大于等于(>=)findByAgeGreaterThanEqual… where x.age >= ?1
After大于(一般用在时间)findByStartDateAfter… where x.startDate > ?1
Before小于(一般用在时间)findByStartDateBefore… where x.startDate < ?1
IsNull是 nullfindByAgeIsNull… where x.age is null
Null是 nullfindByAgeNull… where x.age is null
IsNotNull不是 nullfindByAgeIsNotNull… where x.age not null
NotNull不是 nullfindByAgeNotNull… where x.age not null
Like模糊查询findByFirstnameLike… where x.firstname like ?1
NotLike不模糊查询findByFirstnameNotLike… where x.firstname not like ?1
OrderBy排序findByAgeOrderByLastnameDesc… where x.age = ?1 order by x.lastname desc
NotnotfindByLastnameNot… where x.lastname <> ?1
Inin 查询findByAgeIn(Collection ages)… where x.age in ?1
NotInnot in 查询findByAgeNotIn(Collection ages)… where x.age not in ?1
True是 truefindByActiveTrue()… where x.active = true
False是 falsefindByActiveFalse… where x.active = false
http://www.lryc.cn/news/146428.html

相关文章:

  • Visual Studio 2022的MFC框架——AfxWinMain全局对象和InitInstance函数
  • 【网络】多路转接——poll | epoll
  • 音视频 ffmpeg命令视频录制(Windows)
  • 【拾枝杂谈】从游戏开发的角度来谈谈原神4.0更新
  • QT设置mainwindow的窗口title
  • SaaS多租户系统架构设计
  • Java自定义捕获异常
  • 力扣--数组类题目27. 移除元素
  • 实际并行workers数量不等于postgresql.conf中设置的max_parallel_workers_per_gather数量
  • java定位问题工具
  • 【Java】基础入门 (十六)--- 异常
  • [javaWeb]Socket网络编程
  • <MySon car=“宝马“ :money=“money“></MySon>有没有冒号
  • netty(三):NIO——多线程优化
  • Linux操作系统--linux概述
  • 数组中出现次数超过一半的数字
  • 网络优化工程师,你真的了解吗?
  • git 的常用命令
  • linux如何拷贝文件,删除多余的一级目录,用*号代替所有文件
  • springboot使用properties
  • Android中获取手机SIM卡的各种信息
  • matlab 根据索引提取点云
  • 蓝芯、四川邦辰面试(部分)
  • openCV实战-系列教程13:文档扫描OCR识别下(图像轮廓/模版匹配)项目实战、源码解读
  • SpringBootWeb案例 Part 4
  • 什么是ChatGPT水印,ChatGPT生成的内容如何不被检测出来,原理什么?
  • Android 6.0 Settings中添加虚拟键开关
  • Yolov8小目标检测(12):动态稀疏注意力BiFormer | CVPR 2023
  • C# VS调试技巧
  • VS的调试技巧