S Khandelwal
S Khandelwal

Reputation: 191

How to fetch jsonb column through jpa springboot?

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

Answers (1)

S Khandelwal
S Khandelwal

Reputation: 191

I got the answer. Use

@Query(value="select details->>'value' from table where details->>'name' = 'username'", nativeQuery=true)

Upvotes: 1

Related Questions