亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Spring Data JPA 關鍵字Exists的用法說明

瀏覽:4日期:2023-07-11 16:11:14
Spring Data JPA 關鍵字Exists

查詢數據庫中的此數據是否已存在:

例子:

查詢sys_user表中的一個user是否存在,類SysUser對應的是數據庫中的sys_user表,SysUserId是表sys_user的主鍵類(ID類)。

如果查詢一個user,user的accountNo為demo。

userID為demo1,表sys_user的主鍵是accountNo和userID,下面代碼中的方法是查詢這個user是否存在,如果存在則返回true,不存在則返回false。

@Repositorypublic interface SysUserRepository extends JpaRepository<SysUser, SysUserId> { @Override boolean exists(SysUserId sysUserId);}Spring data jpa支持的關鍵字介紹 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)

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)

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 1024国产精品| 麻豆传媒官网入口 | 新香蕉视频| 亚洲视频综合 | 免费高清在线影片一区 | 欧美日韩系列 | 欧美zzzz| 白眉大侠320回在线收听 | 国产欧美一区二区精品性色 | 中国一级做a爱片免费 | 免费xxxxx大片在线观看影视 | 国产精品日韩欧美亚洲另类 | 亚洲人成网站在线观看播放青青 | 国产高清美女一级毛片久久 | 亚洲a级片在线观看 | 在线观看高清免费 | 粉嫩极品国产在线播放 | 久久精品国产亚洲片 | 欧美区亚洲区 | 国产精品拍拍拍福利在线观看 | 国内精品久久久久 | 亚洲+自拍+色综合图区一 | 午夜久久久 | 91高清在线成人免费观看 | 午夜性视频 | 49pao强力免费打造在线高清 | 香蕉在线观看999 | 久久99爱爱 | 国产精品久久婷婷六月丁香 | 欧美日韩一区二区视频免费看 | 蝌蚪蚪窝视频在线视频手机 | 国产麻豆91网在线看 | 爱爱免费网站 | 97精品高清一区二区三区 | 欧美日韩在线观看精品 | 欧美日韩一区二区三区在线视频 | 国产成人在线观看免费网站 | 日本的黄色录像 | 黄色成人在线网站 | 我要看一级毛片 | 男人天堂综合网 |