db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Allen <...@mojavelinux.com>
Subject Re: Criteria quizz
Date Fri, 14 Mar 2003 14:44:23 GMT
> Now I would like to find all the tasks with no assigned worker.
> 
> How to do it?

Make your life easy and do it in two queries.

 Criteria crit = new Criteria();
 crit.addGroupByColumn(AssignmentPeer.TASK_ID);
 List filledTasks = AssignmentPeer.doSelect(crit);

 List filledTaskIds = new ArrayList();
 Iterator iter = filledTasks.iterator();
 while (iter.hasNext())
 {
     filledTaskIds.add(new Integer(((Task)iter.next()).getTaskId()));
 }
 
 crit.clear();
 crit.add(TaskPeer.TASK_ID, filledTaskIds, Criteria.NOT_IN);
 List unfilledTasks = TaskPeer.doSelect(crit);

voila!

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <dan@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Rumour has it that bad dreams about Windows can be ended by 
putting on a pair of Tux slippers and clicking your heels 
together 3 times while saying. 
"There's no place like /home." 
"There's no place like /home." 
"There's no place like /home."
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Mime
View raw message