我有一个查询,需要查询 每个班级,每月,每周的考核记录. 需要在列表页面显示 班级,月份,周 ,表里存放的某班,某月,某周的所有学生的记录. 在列表页只需要按照班级,月份,周显示数据. 请问如何实现.class ClassCheck 
{
   private Integer month;
   private String classname;
   private Integer week;
...
...
}hql ="select new ClassCheck(distince month ,classname,week )from ClassCheck  c  where  c.classname=:classname  and c. month=:month  and c.week=:week" 我这么写实现不了.我现在需要的结果是 根据班级名,月份,周,查询出不重复的记录,并且查询的结果是封装了对象的 list结果  请问怎么实现. 高分求助

解决方案 »

  1.   

    用group by 班级 ,月份,周
      

  2.   

    hql ="select distinct new ClassCheck(distince month ,classname,week )from ClassCheck c where c.classname=:classname and c. month=:month and c.week=:week";
    这样的结果集是没有重复的,我这么用过的~
      

  3.   

    ClassCheck必须有对应参数的构造方法~
    如果没有则要写一个对应new的构造方法~
    记得保留原来无参的构造方法,不然会出问题滴~