1

I am using spring-data-jpa to run native postgres queries. The query is performed on entity's jsonb data. I can run the raw query on db server with success:

SELECT e.* 
FROM public.entity e where e.json ? 'salary' and e.json ->> 'salary' > '10000';

But, since spring-data-jpa also supports ? for the parameterized queries, there seems to be conflict in the grammer of the query, therefore application eventually fails to even start.

@Query(value = "select e.* from Entity e where e.json ? 'salary' and e.json->> 'salary' > ?1", nativeQuery = true)
List<Lead> getEntitiesBySalaryGreaterThan(String value);

}

Please let me know the workaround or correct way of executing the intended native query in spring-data-jpa env

1 Answer 1

1

Is it possible that you need to escape ? as described here?

Sign up to request clarification or add additional context in comments.

2 Comments

I already have that, If you see ur @query it has two nativeQuery
Thanks man!! Did not know that postgres allows creating custom operators

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.