JPA:方法命名规则

我是 ABin-阿斌:写一生代码,创一世佳话,筑一览芳华。 如果小伙伴们觉得文章有点 feel ,那就点个赞再走哦。
在这里插入图片描述

一、注意:

  • 下面这些方法都是查询操作,方法命名中如果 find 看着可读性不强可以改成 get
  • 这些方法命名,可以让 JPA 底层自动帮我们生成 SQL ,适用于单表、非复杂 SQL 语句实现
  • 如果想要查询 SQL 语句,那么我们可以在日志打印中查看。记得在 YML 中开启日志记录
关键字方法命名sql where字句
AndfindByNameAndPwdwhere name = ? and pwd= ?
OrfindByNameOrSexwhere name = ? or sex =?
BetweenfindByIdBetweenwhere id between ? and ?
LessThanfindByIdLessThanwhere id <?
LessThanEqualfindByIdLessThanEqualwhere id <=?
GreaterThanfindByIdGreaterThanwhere id > ?
GreaterThanEqualfindByIdGreaterThanEqualwhere id >= ?
AfterfindByIdAfterwhere id > ?
Beforefind ByIdBeforewhere id < ?
IsNullfindByNameIsNullwhere name is null
IsNotNull,NotNullfindByNameIsNotNullwhere name is not null
NotNullfindByNameNotNullwhere name is not null
LikefindByNameLikewhere name like ?
NotLikefindByNameNotLikewhere name not like ?
StartingWithfindByNameStartingWithwhere name like ‘?%’
EndingWithfindByNameEndingWithwhere name like ‘%?’
ContainingfindByNameContainingwhere name like ‘%?%’
OrderByfindByIdOrderByAgeDescAndIdAscwhere id = ? order by age desc,id asc
NotfindByNameNotwhere name <> ?
InfindByNameInwhere name in (?)
NotInfindByIdNotInwhere id not in (?)
TruefindByDelStatusTruewhere delStatus = true
FalsefindByDelStatusFalsewhere delStatus = false
IgnoreCasefindByNameIgnoreCasewhere UPPER(name) = UPPER(?)

二、更多细节

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值