Table 2.3. Supported keywords inside method names

Keyword Sample JPQL snippet
And findByLastnameAndFirstname … where x.lastname = ?1 and x.firstname = ?2
Or findByLastnameOrFirstname … where x.lastname = ?1 or x.firstname = ?2
Is,Equals findByFirstname,findByFirstnameIs,findByFirstnameEquals … where x.firstname = 1?
Between findByStartDateBetween … where x.startDate between 1? and ?2
LessThan findByAgeLessThan … where x.age < ?1
LessThanEqual findByAgeLessThanEqual … where x.age <= ?1
GreaterThan findByAgeGreaterThan … where x.age > ?1
GreaterThanEqual findByAgeGreaterThanEqual … where x.age >= ?1
After findByStartDateAfter … where x.startDate > ?1
Before findByStartDateBefore … where x.startDate < ?1
IsNull findByAgeIsNull … where x.age is null
IsNotNull,NotNull findByAge(Is)NotNull … where x.age not null
Like findByFirstnameLike … where x.firstname like ?1
NotLike findByFirstnameNotLike … where x.firstname not like ?1
StartingWith findByFirstnameStartingWith … where x.firstname like ?1 (parameter bound with appended %)
EndingWith findByFirstnameEndingWith … where x.firstname like ?1 (parameter bound with prepended %)
Containing findByFirstnameContaining … where x.firstname like ?1 (parameter bound wrapped in %)
OrderBy findByAgeOrderByLastnameDesc … where x.age = ?1 order by x.lastname desc
Not findByLastnameNot … where x.lastname <> ?1
In findByAgeIn(Collection<Age> ages) … where x.age in ?1
NotIn findByAgeNotIn(Collection<Age> age) … where x.age not in ?1
True findByActiveTrue() … where x.active = true
False findByActiveFalse() … where x.active = false
IgnoreCase findByFirstnameIgnoreCase … where UPPER(x.firstame) = UPPER(?1)

转载于:https://www.cnblogs.com/BenWong/p/3890012.html

Spring Data JPA 查询方法支持的关键字相关推荐

  1. Spring Data JPA 查询方法的命名语法与参数

    3 Spring Data JPA 查询方法的命名语法与参数 在⼯作中,你是否经常为⽅法名的语义.命名规范⽽发愁?是否要为不同的查询条件写各种的 SQL 语句?是否为同⼀个实体的查询,写⼀个超级通⽤的 ...

  2. Spring Data JPA 4.方法定义规范

    方法定义规范 简单条件查询 简单条件查询: 查询某一个实体类或者集合 按照 Spring Data 的规范,查询方法以 find | read | get 开头, 涉及条件查询时,条件的属性用条件关键 ...

  3. spring data jpa 查询自定义字段,转换为自定义实体

    目标:查询数据库中的字段,然后转换成 JSON 格式的数据,返回前台. 环境:idea 2016.3.4, jdk 1.8, mysql 5.6, spring-boot 1.5.2  背景:首先建立 ...

  4. Spring Data JPA 从入门到精通~关键字列表

    注意除了 find 的前缀之外,我们查看 PartTree 的源码,还有如下几种前缀: private static final String QUERY_PATTERN = "find|r ...

  5. 使用Spring Data JPA进行分页和排序

    通过代码示例学习使用Spring Data JPA进行分页和排序 . 了解如何使用Springs PagingAndSortingRepository接口获取分页和排序结果. 1概述 在处理大量数据时 ...

  6. SpringBoot学习笔记:Spring Data Jpa的使用

    更多请关注公众号 Spring Data Jpa 简介 JPA JPA(Java Persistence API)意即Java持久化API,是Sun官方在JDK5.0后提出的Java持久化规范(JSR ...

  7. hql实例 jpa_SpringBoot学习笔记九:Spring Data Jpa的使用

    Spring Data Jpa 简介 JPA JPA(Java Persistence API)意即Java持久化API,是Sun官方在JDK5.0后提出的Java持久化规范(JSR 338,这些接口 ...

  8. ORM框架之Spring Data JPA(二)spring data jpa方式的基础增删改查

    上一篇主要在介绍hibernate实现jpa规范,如何实现数据增删改查,这一篇将会着重spring data jpa 一.Spring Data JPA 1.1 Spring Data JPA介绍: ...

  9. SpringBoot22-spingboot数据访问-Spring Data JPA

    一:点睛Spring Data JPA 1,什么事Spring Data JPA 我们知道Hibernate是数据访问解决技术的绝对霸主,使用O/R映射技术实现数据访问,o/r映射即将领域模型类和数据 ...

最新文章

  1. 构建RESTful风格的WCF服务
  2. 090613 今天做了一个软件没搞定的RAID5
  3. adams建立一绳索不带滑轮_建立企业精益供应链,必须先解开现有绳索 系列(一)...
  4. mysql--SQL编程(关于mysql中的日期,关于重叠) 学习笔记2.2
  5. html做旋转的五角星,如何用几何画板制作旋转的五角星
  6. 数据仓库与ODS的区别
  7. OpenGL 绘制grass草的实例
  8. 公众号新上线微信小游戏(疯狂猜图)
  9. shell 操作(四)
  10. 3D数学基础:矩阵的几何解释
  11. 浅学一下XMind思维导图
  12. php goto解密
  13. 联想小新一键恢复小孔_联想一键恢复系统怎么用?小新Air 13 Pro怎么还原操作系统?...
  14. o.redisson.client.handler.CommandsQueue : Exception occured.
  15. Failed to convert value of type 'java.lang.String' to required type 'java.util.Date
  16. bat中rar压缩命令
  17. Ardupilot环境搭建
  18. 简单了解的分布式术语
  19. 人物抠图 php,php抠图教程(混合模式+剪切蒙版)
  20. Ransom Note

热门文章

  1. 合并两个已经排好序的不等长的数组
  2. 对付ajax ,配置selenium+phantonjs
  3. Linux新手上路命令
  4. SpringMVC_文件上传
  5. (第五篇)Linux操作系统基本结构介绍
  6. .net core 微服务之API网关 开源中间件 Ocelot 笔记
  7. 线程入门-使用Thread类
  8. Linux 挂在命令mount
  9. Android开发(五)——计时器
  10. 《Effective C#》Item 17:减少装箱(Boxing)和拆箱(Unboxing)操作