在 Spring 引导中尝试使用 IN 条件忽略区分大小写时出现 HQL 语法异常

HQL Syntax Exception while trying to Ignore Case Sensitive with IN condition in Spring Boot

同时尝试避免第三个参数的大小写敏感性,即字符串列表(汽车) 通过在 UPPER(?3) 中使用 (UPPER(t.cars) 获取 Hql 语法异常

@Query("select t from Usert where UPPER(t.name) = UPPER(?1) and UPPER(t.age) = UPPER(?2) and (UPPER(t.cars) in UPPER(?3) )")
    List<User> findByNameAndAgeAndCars(String name, String age, List<String> cars);

前两个参数可以与 UPPER() 一起使用,但条件字符串列表不适用于 Upper 如果有人知道解决方案,请告诉我

首先,做类似的事情

for(int i=0; i<cars.size(); i++){
    cars.set(i, cars.get(i).toUpperCase());
}

然后,将您的查询更改为

@Query("select t from Usert where UPPER(t.name) = UPPER(?1) and UPPER(t.age) = UPPER(?2) and (UPPER(t.cars) in (?3) )")