| 
					
						 Using Hibernate 3.0 on a Postgresql 8.0 db, I need to query for a list of objects that have an empty set in a nested association.
 
 Tables:
   tray
     rack
        sample
 
 Associations:
 tray contains 1 or more racks
 rack contains 0 or more samples
 
 I need a list of trays that have no samples in any of its racks.  I have been partially successful using the following Hibernate criteria query...
 
 emptyTrays = HibernateUtil.getSession().createCriteria(Tray.class)
 		.createCriteria("racks", "rack")
 		.add(Expression.isEmpty("rack.samples"))
 		.list();
 
 The only problem seems to be that there are several copies of the same tray in the list... one for each rack in the tray.  For example, if there is 1 empty tray, and that tray has 6 racks, then the resulting list will have 6 Tray objects in it instead of one.
 
 I could do post-processing on the list, but I would like to know if there is a way to use Hibernate to generate a unique list of Tray objects that contain no samples.
 
 Thanks
 Eric- 
											 _________________ Eric Hansen
					
  
						
					 |