I've been tinkering a bit with criteria builder queries to figure out how to check if an array of strings contains a/or many values, but the tricky thing is that this array is inside a jsonb
column called data
. I don't know how to achieve that using CriteriaBuilder queries. I'll paste my psql script below:
SELECT * FROM myScheme.myTable t where t.data->>'categorys' @> '17';
I have done something like this with criteria, but it isn't working
if (Objects.nonNull(filter.getCategorias())) {
predicates.add(builder.and(builder.function("jsonb_extract_path_text",
String.class,
root.get("data"),
builder.literal("categorys"))
.in(filter.getCategorias())));
}
I tried researching how to implement the contains operator @>
but didn't find anything.