That's a report-style query, in which no mapped object is required. Your objects are mapped normally, but you only get a result set of scalars back from your query.
You can use HQL or criteria projections for this. The HQL is almost exactly the same as the equivalent SQL.
Code:
select sum(ca), sev.name, pc.name
from CarAccident ca
join ca.PopulationCenter pc
join ca.AccidentSeverity sev
group by sev.name, pc.name
The criteria uses Projections:
Code:
Criteria crit = session.createCriteria(CarAccident.class, "ca");
Projection proj = Projections.projectionList();
proj.add(Projections.groupProperty("sev.name");
proj.add(Projections.groupProperty("pc.name");
proj.add(Projections.sum("ca.id"));
crit.setProjection(proj);
crit.createAlias("ca.PopulationCenter", "pc");
crit.createAlias("ca.AccidentSeverity", "sev");
return crit.list();
Is this what you wanted to know?