java - Criteria api JSON field condition - Stack Overflow

There is a complex multiconditional method, based on Criteria Api in a Spring application. I need to ad

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

相关推荐

  • java - Criteria api JSON field condition - Stack Overflow

    There is a complex multiconditional method, based on Criteria Api in a Spring application. I need to ad

    22小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信