Criteria c = session.createCriteria(target);
Criteria ann = session.createCriteria(target); ann.createAlias("details.creationEvent", "ann_create"); ann.createAlias("details.updateEvent", "ann_update"); ann.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); ann.add(Restrictions.in(path+".id",(Collection) value(IDS)));
    protected void buildQuery(Session session)         throws HibernateException, SQLException    {        PojoOptions po = new PojoOptions((Map) value(OPTIONS));        Class k = (Class) value(CLASS);        if ( ! typeToAnnotationType.containsKey( k ))        {            throw new IllegalArgumentException(                    "Class "+k+" is not accepted by "+                    PojosFindAnnotationsQueryDefinition.class.getName()                    );        }                Class target = typeToAnnotationType.get((Class) value(CLASS));        String path = annotationTypeToPath.get(target);                Criteria c = session.createCriteria(target);                c.createCriteria(path,LEFT_JOIN);        c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);        c.add(Restrictions.in(path+".id",(Collection) value(IDS)));                if (check("annotatorIds"))        {            Collection annotatorIds = (Collection) value("annotatorIds");            if (annotatorIds != null && annotatorIds.size() > 0)                c.add(Restrictions.in("details.id", annotatorIds ));        }        setCriteria( c );    }