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函数。

posted @ 2018-10-26 03:47  EasonJim  阅读(1959)  评论(0编辑  收藏  举报