欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Data JPA 關(guān)鍵字Exists的用法說明

 更新時間:2021年06月10日 11:53:45   作者:Jim~LoveQ  
這篇文章主要介紹了Spring Data JPA 關(guān)鍵字Exists的用法說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

Spring Data JPA 關(guān)鍵字Exists

查詢數(shù)據(jù)庫中的此數(shù)據(jù)是否已存在:

例子:

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

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

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

@Repository
public interface SysUserRepository extends JpaRepository<SysUser, SysUserId> {
    @Override
    boolean exists(SysUserId sysUserId);
}

Spring data jpa支持的關(guān)鍵字介紹

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)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 死磕 java同步系列之synchronized解析

    死磕 java同步系列之synchronized解析

    這篇文章主要介紹了Java中syncronized正確使用方法解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2021-06-06
  • Java微信公眾平臺開發(fā)(2) 微信服務(wù)器post消息體的接收

    Java微信公眾平臺開發(fā)(2) 微信服務(wù)器post消息體的接收

    這篇文章主要為大家詳細介紹了Java微信公眾平臺開發(fā)第二步,微信服務(wù)器post消息體的接收,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • java觀察者模式實現(xiàn)和java觀察者模式演化

    java觀察者模式實現(xiàn)和java觀察者模式演化

    觀察者模式是經(jīng)典設(shè)計模式中很常用的一種,平常我們看到的監(jiān)聽器,基本上都是采用這種設(shè)計模式實現(xiàn)的,這里探討一下觀察者模式的演化
    2014-02-02
  • Springboot+ElementUi實現(xiàn)評論、回復(fù)、點贊功能

    Springboot+ElementUi實現(xiàn)評論、回復(fù)、點贊功能

    這篇文章主要介紹了通過Springboot ElementUi實現(xiàn)評論、回復(fù)、點贊功能。如果是自己評論的還可以刪除,刪除的規(guī)則是如果該評論下還有回復(fù),也一并刪除。需要的可以參考一下
    2022-01-01
  • java 獲取日期的幾天前,幾個月前和幾年前的實例

    java 獲取日期的幾天前,幾個月前和幾年前的實例

    下面小編就為大家?guī)硪黄猨ava 獲取日期的幾天前,幾個月前和幾年前的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • Mybatis攔截器打印sql問題

    Mybatis攔截器打印sql問題

    這篇文章主要介紹了Mybatis攔截器打印sql問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • idea.vmoptions 最佳配置方案

    idea.vmoptions 最佳配置方案

    本文介紹了針對IntelliJ IDEA的優(yōu)化配置建議,包括提升內(nèi)存設(shè)置、啟用G1垃圾回收器、優(yōu)化垃圾回收策略以及調(diào)整網(wǎng)絡(luò)設(shè)置等,旨在提高IDE的性能和響應(yīng)速度,同時,指導(dǎo)用戶如何修改vmoptions文件以應(yīng)用這些配置,并提供了監(jiān)控內(nèi)存使用和插件管理的建議
    2024-09-09
  • Java實現(xiàn)動態(tài)驗證碼生成

    Java實現(xiàn)動態(tài)驗證碼生成

    這篇文章主要為大家詳細介紹了Java實現(xiàn)動態(tài)驗證碼生成,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Java Swing SpringLayout彈性布局的實現(xiàn)代碼

    Java Swing SpringLayout彈性布局的實現(xiàn)代碼

    這篇文章主要介紹了Java Swing SpringLayout彈性布局的實現(xiàn)代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • 詳解spring applicationContext.xml 配置文件

    詳解spring applicationContext.xml 配置文件

    本篇文章主要介紹了詳解spring applicationContext.xml 配置文件 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02

最新評論