Reputation: 191
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.
Upvotes: 1
Views: 185
Reputation: 191
I got the answer. Use
@Query(value="select details->>'value' from table where details->>'name' = 'username'", nativeQuery=true)
Upvotes: 1