Say i have a db-table looking like this:
CREATE TABLE myTable(
id BIGINT,
date TIMESTAMP,
user_ids JSONB
);
user_ids
are a JSONB-ARRAY
Let a record of this table look like this:
{
"id":13,
"date":"2019-01-25 11:03:57",
"user_ids":[25, 661, 88]
};
I need to query all records where user_ids contain 25. In SQL i can achieve it with the following select-statement:
SELECT * FROM myTable where user_ids::jsonb @> '[25]'::jsonb;
Now i need to write a JPA-Predicate that renders "user_ids::jsonb @> '[25]'::jsonb"
to a hibernate parseable/executable Criteria, which i then intent to use in a session.createQuery()
statement.
In simpler terms i need to know how i can write that PSQL-snippet (user_ids::jsonb @> '[25]'::jsonb)
as a HQL-expression.