jpa @Query demo 演示
package com.lyr.easymybatis.repository;
import com.lyr.easymybatis.pojo.po.ApiInfoDemo;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
* 參考資料:
* https://blog.csdn.net/qq_39264897/article/details/105106375
*
*
*
* @Author lyr
* @create 2020/12/14 22:32
*/
public interface ApiInfoDemoRepository extends JpaRepository<ApiInfoDemo,Long> {
/**
* url like
* or
* title like
* or
* markdownInfo like
*
*
* @param searchText
* @return
*/
List<ApiInfoDemo> findByUrlContainingOrTitleContainingOrMarkdownInfoContaining(String searchText,String searchText2,String txt);
@Query(value = "select a from ApiInfoDemo a where a.markdownInfo like %:q%" )
List<ApiInfoDemo> searchByTxt(@Param("q") String q);
}
分頁查詢:
package com.lyr.easymybatis.repository;
import com.lyr.easymybatis.pojo.po.ApiInfoDemo;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
* 參考資料:
* https://blog.csdn.net/qq_39264897/article/details/105106375
*
*
*
* @Author lyr
* @create 2020/12/14 22:32
*/
public interface ApiInfoDemoRepository extends JpaRepository<ApiInfoDemo,Long> {
/**
* url like
* or
* title like
* or
* markdownInfo like
*
*
* @param searchText
* @return
*/
List<ApiInfoDemo> findByUrlContainingOrTitleContainingOrMarkdownInfoContaining(String searchText,String searchText2,String txt);
@Query(value = "select a from ApiInfoDemo a where a.markdownInfo like %:q%" )
List<ApiInfoDemo> searchByTxt(@Param("q") String q,Pageable pageable);
}
@Test
void queryLLL() {
System.out.println(
apiInfoDemoRepository
.searchByTxt("world",PageRequest.of(0,10))
);
}
注意:要從 第0頁開始,外國人從0開始的
相關文章
- Spring Data JPA REST Query CriteriaSpringREST
- 【SpringBoot Demo】MySQL + JPA + Hibernate + Springboot + Maven DemoSpring BootMySqlMaven
- @Query註解的用法(Spring Data JPA)Spring
- Spring Data JPA 在 @Query 中使用投影的方法Spring
- 針對microsvs/base業務框架的DEMO演示ROS框架
- SignalR簡版web聊天室(demo簡單演示篇)SignalRWeb
- jpa+querydsl的平替國產easy-query最好用的ormORM
- flight-tracker-demo:一個Quarkus + Kafka演示原始碼專案Kafka原始碼
- demo演示如何寫一個無配置格式統一的日誌
- iOS多執行緒之超實用理論+demo演示(可下載)iOS執行緒
- CANoe C-V2X Demo(V2I+V2V)演示視訊
- JPA與hibernate-------JPA01
- PingCAP 唐劉:一個諮詢顧問對 TiDB Chat2Query Demo 提出的腦洞PingCAPTiDB
- JPA
- Query DSL
- reg query /?
- ES 筆記十:Query String & Simple Query String筆記
- Sitecore10 Demo演示環境Azure一鍵部署(Step By Step Guide to installing Sitecore10 in Azure Paas)GUIIDE
- Qt+MPlayer音樂播放器開發筆記(一):ubuntu上編譯MPlayer以及Demo演示QT播放器筆記Ubuntu編譯
- coca SLOW QUERY
- expdp query用法
- Flashback Query(轉)
- Elasticsearch——query stringElasticsearch
- react-query手把手教程①-入門react-queryReact
- Spring Data JpaSpring
- SpringBoot使用JPASpring Boot
- JPA入門
- NeurIPS 2018首日:阿里霸氣演示全中文Demo,谷歌釋出“找新娘”圖片識別競賽阿里谷歌
- [Typescript] Query builder exampleTypeScriptUI
- pt-query-digest
- jpa報錯 Failed to initialize JPA EntityManagerFactory: Unable to instantiate default tuplizerAI
- Spring Data JPA之Spring Data JPA快速入門(三)Spring
- demo
- Spring Data JPA系列2:SpringBoot整合JPA詳細教程,快速在專案中熟練使用JPASpring Boot
- GraphQL案例演示
- ntpdate會導致mysql slow query log出現很大的query timeMySql
- JPA中@ElementCollection使用
- Jpa使用詳解