gpt4 book ai didi

Hibernate 标准限制 AND/OR 组合

转载 作者:行者123 更新时间:2023-12-03 05:33:15 30 4
gpt4 key购买 nike

如何使用 Hibernate 限制来实现此目的?

(((A='X') and (B in('X',Y))) or ((A='Y') and (B='Z')))

最佳答案

思考有效

Criteria criteria = getSession().createCriteria(clazz); 
Criterion rest1= Restrictions.and(Restrictions.eq(A, "X"),
Restrictions.in("B", Arrays.asList("X",Y)));
Criterion rest2= Restrictions.and(Restrictions.eq(A, "Y"),
Restrictions.eq(B, "Z"));
criteria.add(Restrictions.or(rest1, rest2));

关于Hibernate 标准限制 AND/OR 组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8126589/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com