String q = "select new com.lufthansatechnik.mscoreengine.homes.DepartmentScore(" +
" scoreEntry.department.id, scoreEntry.department.name, scoreEntry.yearMonth, sum(scoreEntry.score)) " +
"from ScoreEntry scoreEntry " +
"where scoreEntry.yearMonth >= :startMonth and scoreEntry.yearMonth <= :endMonth " +
"group by scoreEntry.department.id, scoreEntry.department.name, scoreEntry.yearMonth";
List a = entityManager.createQuery(q)
.setParameter("startMonth", startYearMonth)
.setParameter("endMonth", endYearMonth)
.getResultList();