Search code examples
sqlspringspring-boothql

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


while trying to avoid Case Sensitiveness of 3rd Param which is List of String(Cars) by using (UPPER(t.cars) in UPPER(?3) Getting Hql Syntax exception

@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);

first two param able to work with UPPER() but list of String In Condition is not work with Upper if any body knows the solution could you please let me know


Solution

  • First, do something like

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

    then, change your query to something like

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