C
comp.lang.java.programmer
Hi
I'm looking for a way to implement a query using Hibernate Criteria/Restrictions
The query would be along the lines of
(ConditionA) and (ConditionB and ConditionC and ConditionD)
But I couldn't see how the Criteria API allows logical combinations/grouping?
In other words
where (colA = 'aa') and (colb != 'bb' AND colC != 'cc' AND colD != 'dd')
Actually I couldn't even figure out how to do the second part because
criteria.add(Restrictions.ne("colB", "bb");
criteria.add(Restriction.ne("colC", "cc");
criteria.add(Restriction.ne("colD", dd");
seems to equate to
where colb != 'bb' AND colC != 'cc' AND cold != 'dd'
In other words there's no parenthesis around the three conditions
and so it returns all records because the three conditions must be applied together to eliminate one single record.
I thought maybe something like Restrict.allEq
might have an equivalent Restrict.allNe
Or that maybe the Example would have an inverse operation to return all records "not matching" the example.
Regards.
I'm looking for a way to implement a query using Hibernate Criteria/Restrictions
The query would be along the lines of
(ConditionA) and (ConditionB and ConditionC and ConditionD)
But I couldn't see how the Criteria API allows logical combinations/grouping?
In other words
where (colA = 'aa') and (colb != 'bb' AND colC != 'cc' AND colD != 'dd')
Actually I couldn't even figure out how to do the second part because
criteria.add(Restrictions.ne("colB", "bb");
criteria.add(Restriction.ne("colC", "cc");
criteria.add(Restriction.ne("colD", dd");
seems to equate to
where colb != 'bb' AND colC != 'cc' AND cold != 'dd'
In other words there's no parenthesis around the three conditions
and so it returns all records because the three conditions must be applied together to eliminate one single record.
I thought maybe something like Restrict.allEq
might have an equivalent Restrict.allNe
Or that maybe the Example would have an inverse operation to return all records "not matching" the example.
Regards.