paramMap.put("submitDateYear", paramMap.get("submitDateYear") + "%");
StringBuffer hql = new StringBuffer();
hql.append(" select new TempDeptRectPatrol" +
"(" +
" t.submitDate," +
" sum(t.findProblem1)," +
" sum(t.rectProblem1)," +
" sum(t.findProblem2)," +
" sum(t.rectProblem2)," +
" sum(t.findProblem3)," +
" sum(t.rectProblem3)," +
" sum(t.findProblem4)," +
" sum(t.rectProblem4)," +
" sum(t.findProblem5)," +
" sum(t.rectProblem5)," +
" sum(t.findProblem6)," +
" sum(t.rectProblem6)," +
" sum(t.findProblem7)," +
" sum(t.rectProblem7)," +
" sum(t.findProblem8)," +
" sum(t.rectProblem8)," +
" sum(t.findProblem9)," +
" sum(t.rectProblem9)," +
" sum(t.findProblem10)," +
" sum(t.rectProblem10)" +
")");
hql.append(" from TempDeptRectPatrol t");
hql.append(" where 1 = 1 ");
hql.append(" and t.submitDate like :submitDateYear");
hql.append(" group by submitDate");
关键在于,要在实体 TempDeptRectPatrol 写一个构造函数 如下:
public TempDeptRectPatrol(String _submitDate,Long _findProblem1,Long _rectProblem1,Long _findProblem2,Long _rectProblem2,Long _findProblem3,Long _rectProblem3
,Long _findProblem4,Long _rectProblem4,Long _findProblem5,Long _rectProblem5,Long _findProblem6,Long _rectProblem6,Long _findProblem7,Long _rectProblem7
,Long _findProblem8,Long _rectProblem8,Long _findProblem9,Long _rectProblem9,Long _findProblem10,Long _rectProblem10){
this.submitDate = _submitDate;
this.findProblem1 = _findProblem1;
this.rectProblem1 = _rectProblem1;
this.findProblem2 = _findProblem2;
this.rectProblem2 = _rectProblem2;
this.findProblem3 = _findProblem3;
this.rectProblem3 = _rectProblem3;
this.findProblem4 = _findProblem4;
this.rectProblem4 = _rectProblem4;
this.findProblem5 = _findProblem5;
this.rectProblem5 = _rectProblem5;
this.findProblem6 = _findProblem6;
this.rectProblem6 = _rectProblem6;
this.findProblem7 = _findProblem7;
this.rectProblem7 = _rectProblem7;
this.findProblem8 = _findProblem8;
this.rectProblem8 = _rectProblem8;
this.findProblem9 = _findProblem9;
this.rectProblem9 = _rectProblem9;
this.findProblem10 = _findProblem10;
this.rectProblem10 = _rectProblem10;
}