two than more example clase hibernate criteria hibernate-criteria restrictions

than - Restricciones de criterios de Hibernate Y/O combinación



hibernate restrictions or more than two (1)

¿Cómo lograría esto usando Restricciones de Hibernate?

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


creo que funciona

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));