Hi
I'm new to hibernate and think I'm close. I'm trying to convert this simple sql "select * from (select count(*),unit from usage group by unit) as totalusage where totalusage.count < 20;" to criteria based api.
I keep on getting into trouble in referencing total usage as an alias and in returning more than one column from my subquery. I think I'm close DetachedCriteria detached = DetachedCriteria.forClass(Unit.class); Long u = new Long(20); detached.setProjection(Projections.projectionList().add(Projections.rowCount(), "rowCount"). add(Projections.groupProperty("unit"))).addOrder(Order.desc("rowCount")).add(Restrictions.le("rowCount", u)); list = detached.getExecutableCriteria(session).list(); System.out.println(list); and I get the error "Could not resolve rowCount". thanks, Ollie22
|