I haven't been able to find any good tutorials on Criteria API, but the following HQL is generated based upon the number of predicates passed in. For example, there isn't a need to do a left outer join if there are no predicates and there isn't a need to check the predicate name/value also.
I know using the Criteria API would help clean up this logic, but I can't see how to handle the left outer join.
Point will be awarded based upon an insightful answer.
Code:
select 
   nt 
from 
   type nt, 
   blah n, 
   other ne 
   left outer join ne.predicates 
   as preds 
   where n.application = ne.application and 
   n.event = ne.event and 
   ne.predicateCount = :count and 
   n.notificationType = nt.type and 
   n.application = nt.application and 
   n.application = :application and 
   n.event = :event and 
   n.setId = preds.setId and  
   (
      (preds.name = :name0 and preds.value in (:value0, 'ANY'))
   ) 
group by 
   nt.application, 
   nt.subscriber, 
   nt.type, 
   nt.value 
having count(*) = :having_count
Thank you!