最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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對應的是數(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中LinkedList真的是查找慢增刪快

    Java中LinkedList真的是查找慢增刪快

    這篇文章主要介紹了Java中LinkedList真的是查找慢增刪快,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-10-10
  • Spring空值和特殊字符的注入方式

    Spring空值和特殊字符的注入方式

    文章介紹了如何通過創(chuàng)建類、配置文件和測試代碼來實現(xiàn)空值和特殊字符注入,具體包括定義屬性、生成set方法、配置對象創(chuàng)建和屬性注入、以及編寫測試代碼進行驗證
    2024-11-11
  • Spring中自定義數(shù)據(jù)類型轉(zhuǎn)換的方法詳解

    Spring中自定義數(shù)據(jù)類型轉(zhuǎn)換的方法詳解

    Spring3引入了一個core.onvert包,提供一個通用類型轉(zhuǎn)換系統(tǒng)。在Spring容器中,可以使用這個系統(tǒng)作為PropertyEditor實現(xiàn)的替代,將外部化的bean屬性值字符串轉(zhuǎn)換為所需的屬性類型。本文將詳解這一系統(tǒng)的使用方法,需要的可以參考一下
    2022-06-06
  • IntelliJ IDEA中使用mybatis-generator的示例

    IntelliJ IDEA中使用mybatis-generator的示例

    這篇文章主要介紹了IntelliJ IDEA中使用mybatis-generator,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-04-04
  • Java文件字符輸入流FileReader讀取txt文件亂碼的解決

    Java文件字符輸入流FileReader讀取txt文件亂碼的解決

    這篇文章主要介紹了Java文件字符輸入流FileReader讀取txt文件亂碼的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • Lombok中關(guān)于@Data的使用解析

    Lombok中關(guān)于@Data的使用解析

    這篇文章主要介紹了Lombok中關(guān)于@Data的使用解析,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Java編寫實現(xiàn)窗體程序顯示日歷

    Java編寫實現(xiàn)窗體程序顯示日歷

    這篇文章主要為大家詳細介紹了Java編寫實現(xiàn)窗體程序顯示日歷,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • 簡單講解在Java編程中實現(xiàn)設(shè)計模式中的單例模式結(jié)構(gòu)

    簡單講解在Java編程中實現(xiàn)設(shè)計模式中的單例模式結(jié)構(gòu)

    這篇文章主要介紹了簡單講解在Java編程中實現(xiàn)設(shè)計模式中的單例模式結(jié)構(gòu),設(shè)計模式是最基本直白簡單的一種設(shè)計模式,需要的朋友可以參考下
    2016-04-04
  • 詳解Java中clone的寫法

    詳解Java中clone的寫法

    這篇文章主要介紹了Java中clone的寫法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-07-07
  • 詳解idea打包jar的多種方式

    詳解idea打包jar的多種方式

    本篇文章總結(jié)出用IDEA打包jar包的多種方式。項目打包Jar包可以參考如下形式:用IDEA自帶的打包形式;用Maven插件maven-shade-plugin打包;用Maven插件maven-assembly-plugin打包。下面跟著小編一起來看下吧
    2017-01-01

最新評論

新沂市| 肇源县| 永登县| 习水县| 视频| 昌平区| 长汀县| 文化| 方山县| 沙雅县| 阿克陶县| 师宗县| 任丘市| 上蔡县| 南川市| SHOW| 盐源县| 凤山市| 库伦旗| 海兴县| 锡林郭勒盟| 延川县| 德兴市| 黄冈市| 古蔺县| 卫辉市| 澄迈县| 兴文县| 华安县| 于都县| 彭阳县| 徐州市| 萨嘎县| 章丘市| 东丰县| 班戈县| 岳普湖县| 中卫市| 宣城市| 黄龙县| 庐江县|