I have a custom util class called LessonView. It looks like this:
public class LessonView{ private String subject; private int year, count; public LessonView(){} public LessonView(String subject, int year, int count){ sets the variables via setters } public getters and setters }
"select new LessonView(l.subject, l.year, count(*)) from Lesson l group by l.lesson, l.year order by l.lesson, l.year";