Hi, is there any way to simulate universal quantifier (for all) using criteria? E.g. I have object Employee and Task in OneToMany association.
Employee 1 ----- * Task
Task has status attribute. I would like to select all Employees, which have all their tasks in status DONE.
Easiest way to do this is rewrite FORALL Condition to NOT EXISTS (NOT Condition) which can be written in SQL:
select * from employee where not exists (select * from task where task.employee_id = employee.id and (task.status <> 'DONE'))
This is easy in SQL but I want to use Criteria. I tried Subqueries.exists and always got an Exception. If it is possible I don't want to use exists quantifier because it executes select for every employee.
Is there any way how to select all Employees, which have all their tasks in status DONE, the best without using subqueries.
Thanks
|