I have one table which contains one column 'details' as jsonb data type. The content is
{
"name": "username",
"value": "user1",
"is_required": true
}
for one row. I want to write one jpa hibernate query in spring boot to fetch this record when name == username for details column.
Something like this:
select details->>'value' from table where details->>'name' = 'username';
This syntax does not work in spring boot hibernate query.
asked Mar 28, 2019 at 9:16
-
1Possible duplicate of How do I use spring data jpa to query jsonb column?Mebin Joe– Mebin Joe2019年03月28日 09:41:54 +00:00Commented Mar 28, 2019 at 9:41
-
It does not help.S Khandelwal– S Khandelwal2019年05月16日 12:13:46 +00:00Commented May 16, 2019 at 12:13
1 Answer 1
I got the answer. Use
@Query(value="select details->>'value' from table where details->>'name' = 'username'", nativeQuery=true)
answered Mar 28, 2019 at 10:28
Sign up to request clarification or add additional context in comments.