Spring Data JPA使用keywords關鍵字實現CAST函數


對不起,經過幾天幾夜的使用的研究得出這種方式是無法實現的,在查詢上的關鍵字只有這些:

https://docs.spring.io/spring-data/jpa/docs/2.1.x/reference/html/#_supported_query_keywords

https://docs.spring.io/spring-data/jpa/docs/2.1.x/reference/html/#repository-query-keywords

要想實現比如CAST這些函數就必須要自己手寫SQL語句。又或者這樣用:

predicates.add(criteriaBuilder.like(criteriaBuilder.lower(root.get("industryId").as(String.class)),"%1%"));

查詢時使用as轉換成String,這樣聲稱出來的SQL就是CAST函數。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM