久久天天躁狠狠躁夜夜免费观看,精品国产粉嫩内射白浆内射双马尾,久久国产欧美日韩精品,久久久久久性高,激情欧美成人久久综合

Spring JPA查詢,JPA 根據(jù)方法名字查詢詳細(xì)介紹

JSON 2018-04-22 21:11:33 77517

  JPA  的查詢有很多豐富的API,基本能滿足了所有的基本查詢。下面來想細(xì)說說支持的查詢方式。


根據(jù)方法名字生成SQL語句(根據(jù)方法名查詢)。

public interface UserRepository extends Repository<User, Long> {

  List<User> findByEmailAddressAndLastname(String emailAddress, String lastname);
}

我們將使用JPA criteria API創(chuàng)建一個(gè)查詢,但本質(zhì)上這轉(zhuǎn)換為以下查詢:

select u from User u where u.emailAddress = ?1 and u.lastname = ?2

Spring Data  JPA  將執(zhí)行屬性檢查并遍歷屬性表達(dá)式中描述的嵌套屬性。下面是  JPA  支持的關(guān)鍵字的概述,以及包含該關(guān)鍵字的方法的本質(zhì)含義。

SQL關(guān)鍵詞想細(xì)介紹

關(guān)鍵詞 Demo JPQL 語句片段
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)

自己可以各種嘗試。


版權(quán)所屬:SO JSON在線解析

原文地址:http://suancuo.cn/blog/295.html

轉(zhuǎn)載時(shí)必須以鏈接形式注明原始出處及本聲明。

本文主題:

如果本文對你有幫助,那么請你贊助我,讓我更有激情的寫下去,幫助更多的人。

關(guān)于作者
上天我不能,入地我不愿,我只能徘徊于天地之間。生當(dāng)夏花,死而無憾!
相關(guān)文章
解JavaScript中splice()方法,有Demo詳細(xì)介紹
Elasticsearch 教程,Elasticsearch 日期查詢解,Elasticsearch Date 查詢Java API
Elasticsearch教程 ,Elasticsearch count 查詢,Elasticsearch 查詢是否存在
Elasticsearch教程(九) elasticsearch 查詢數(shù)據(jù) | 分頁查詢
Druid數(shù)據(jù)庫配置詳細(xì)介紹。網(wǎng)上一團(tuán)糟。
IP地址查詢,IP定位,IP純真數(shù)據(jù)查詢
好用的區(qū)號查詢工具 | 所在地區(qū)號查詢
公安局網(wǎng)站備案信息查詢API,免費(fèi)查詢公安網(wǎng)備 API 代碼說明
whois查詢是什么?它有哪些作用?
如何查詢自己的郵政編碼?
最新文章
計(jì)算機(jī)網(wǎng)絡(luò)的相關(guān)內(nèi)容 354
SOJSON V6 JavaScript 解密技巧與分析 5940
微信客服人工電話95068:如何快速解封微信賬號(2025最新指南) 11885
Java Http請求,HttpURLConnection HTTP請求丟失頭信息,Head信息丟失解決方案 5052
實(shí)用API合集分享:教你輕松獲取IP地址的API合集 8839
Linux I/O重定向 6705
Ruby 循環(huán) - while、for、until、break、redo 和 retry 3990
Node.js:全局對象 3604
如何使用終端檢查Linux上的內(nèi)存使用情況 3779
JavaScript對象詳細(xì)剖析 3252
最熱文章
免費(fèi)天氣API,天氣JSON API,不限次數(shù)獲取十五天的天氣預(yù)報(bào) 745370
最新MyEclipse8.5注冊碼,有效期到2020年 (已經(jīng)更新) 703112
蘋果電腦Mac怎么恢復(fù)出廠系統(tǒng)?蘋果系統(tǒng)怎么重裝系統(tǒng)? 678428
Jackson 時(shí)間格式化,時(shí)間注解 @JsonFormat 用法、時(shí)差問題說明 561958
我為什么要選擇RabbitMQ ,RabbitMQ簡介,各種MQ選型對比 511823
Elasticsearch教程(四) elasticsearch head 插件安裝和使用 483716
Jackson 美化輸出JSON,優(yōu)雅的輸出JSON數(shù)據(jù),格式化輸出JSON數(shù)據(jù)... ... 299543
Java 信任所有SSL證書,HTTPS請求拋錯,忽略證書請求完美解決 246654
Elasticsearch教程(一),全程直播(小白級別) 232088
227528
支付掃碼

所有贊助/開支都講公開明細(xì),用于網(wǎng)站維護(hù):贊助名單查看

查看我的收藏

正在加載... ...