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

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

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

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

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

例子:

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

如果查詢一個(gè)user,user的accountNo為demo。

userID為demo1,表sys_user的主鍵是accountNo和userID,下面代碼中的方法是查詢這個(gè)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)

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

相關(guān)文章

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

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

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

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

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

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

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

    IntelliJ IDEA中使用mybatis-generator的示例

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

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

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

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

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

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

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

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

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

    詳解Java中clone的寫法

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

    詳解idea打包jar的多種方式

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

最新評(píng)論

舟山市| 石林| 革吉县| 高淳县| 福建省| 保康县| 霞浦县| 陆河县| 顺义区| 稻城县| 高碑店市| 遂溪县| 荣昌县| 奉节县| 林甸县| 娄烦县| 上林县| 垦利县| 隆尧县| 花莲县| 柘荣县| 渑池县| 天水市| 富平县| 鲁甸县| 波密县| 平凉市| 铅山县| 宕昌县| 江达县| 齐齐哈尔市| 崇明县| 静安区| 图木舒克市| 崇阳县| 南开区| 肥东县| 郴州市| 三江| 姚安县| 寿宁县|