Reputation: 681
I have tried this query:
@Query(value = "SELECT distinct `id`,`customer name`,`customer number` FROM My_Data WHERE `customer number` like '%"
+ ":customerNumber" + "%'", nativeQuery = true)
public List<MyData> findDistinctByCustomerNumberContainingIgnoreCase(
@Param("customerNumber") String customerNumber);
When I run this, I get:
java.lang.IllegalArgumentException: Parameter with that position [1] did not exist exception.
I want a native query due to some restrictions I have with my table.
Upvotes: 1
Views: 2449
Reputation: 26502
You have put the placeholder within parentheses and the engine treats it like a plain string.
If you surround it simply with %, the engine will know to parse that adding the parentherses in the resolved query:
@Query(value = "SELECT distinct `id`,`customer name`,`customer number` FROM My_Data
WHERE `customer number` like %:customerNumber%", nativeQuery = true)
Upvotes: 1