'How to query a column which value is null and use keyword `in` in JPA?
When I passing parameters a1 as "a1", a2 as ["a21","a22"]
@Query(value = "select * from a where if(:a1 !='', a1=:a1,1=1)"
+ "and if(:a2 !='',a2 in (:a2), 1=1)", nativeQuery = true)
List<A> method(@Param("a1") String a1,
@Param("a2") List<String> a2);
There will be an exception:you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1=1) at line 1 What's wrong with this problem? How to solve it in a right way? Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
