對不起,經過幾天幾夜的使用的研究得出這種方式是無法實現的,在查詢上的關鍵字只有這些:
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函數。