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