There is a complex multiconditional method, based on Criteria Api in a Spring application. I need to add one more condition without changing the approach. In native SQL it looks like:
select * from some_view where ... or exists(SELECT 1 FROM jsonb_array_elements(tags) AS tag
WHERE tag ->> 'name' IN ('#aaa', '#bbb'));
I know how to call this function, but it's not clear for me how to access the fields of result like 'name' and place it to 'in' predicate.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
List<Predicate> predicates = new ArrayList<>();
Expression<Tag> function = builder.function("jsonb_array_elements",
Tag.class, root.get("tags"));
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745043258a4607939.html
评论列表(0条)