I am trying to user Postgres jsonb string exist operator in the SpringData native query.
SpringData method example:
@Query(value = "SELECT t.id \n"
+ " FROM task AS t \n"
+ " WHERE (t.worker_ids \\? :workerId)\n"
+ " ORDER BY t.created_at\n",
nativeQuery = true)
Optional<String> findMatchingTaskId(@Param("workerId") String workerId);
Where worker_ids
is of type JSOB in the database.
I've tried to exclude question mark with \\
but still got below error :
org.postgresql.util.PSQLException: No value specified for parameter 2.
Is there a way to use this operator with spring data native query?