Reputation: 103
I have to write a JPQL query in spring boot which is equivalent to the below query.
QUERY:
SELECT * FROM flow.logs where feature_id like '%|data:6789%';
JPQL Query made by me:
@Query("SELECT logs FROM Logs logs WHERE logs.featureId like '%|data\\: :data%'")
public List<Logs> getLogsByStationId(@Param("data")Integer data);
The query is not working and giving the below exception:
Unknown parameter position: 1; nested exception is
java.lang.IllegalArgumentException: Unknown parameter position: 1
Can anyone tell me what is wrong with my code.
Upvotes: 1
Views: 1618
Reputation: 416
You can use the CONCAT function like this :
@Query("SELECT logs FROM Logs logs WHERE "
+ "logs.featureId like CONCAT('%|data:', :data, '%')")
Upvotes: 2