I'm facing a problem filtering rows by property in a jsonb
column type.
I tried this:
jsonb_column ? 'my_property'
On pgadmin
or psql
it works well, but over a JDBC driver it throws the error:
org.hibernate.QueryException: Expected positional parameter count: 3, actual parameters: []
The problem is with the ?
operator. So, there're another way to do that?
well, after some researches and no one solution to my problem with the "?" operator over de JDBC driver, I solved it another way, the function
jsonb_object_keys
returns all keys of my json element, and then I filter each one using the <@ operator like:
ARRAY(SELECT jsonb_object_keys(jsonb_column)) <@ '{property1,property2,property3}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.