hibernate 多表之間的統計語句 (程式碼)

chenyinan119發表於2008-03-12

介面實現類:

public List getAllEmployeeAttend(){
String hql_two = "SELECT p.projectName , sci.stuffName ,count(att.onDuty) AS a ,count(att.usualOvertime) AS b ," +

"count(att.unusualOvertime) AS c , count(att.late) AS d ," +

"count(att.early) AS e , count(att.sickLeave) AS f ," +

"count(att.privateAffairLeave) AS g , count(att.evection) AS h ," +

"count(att.payLeave) AS i , count(att.waitPay) AS j " +

"FROM Attendper att LEFT JOIN att.projectInfo p INNER JOIN att.sci sci " +

"WHERE att.attendperDate >= '2008-02-01' AND att.attendperDate <= '2008-02-29' " +

"GROUP BY sci.stuffName , p.projectName " ;
List list = null;
try
{
Query q = this.getSession().createQuery( hql_two );
list = q.list();
//list = getHibernateTemplate().find(hql);
}catch(Exception e){
e.printStackTrace();
}
return list;
}

Action :

AttendDao ad = (AttendDao)getBean("attendDao");
// 得到全部員工的列表
List list=ad.getAllEmployeeAttend();
request.setAttribute("list",list);
return mapping.findForward("***");

page :

List l = (List)request.getAttribute("list") ;
for(Iterator it = l.iterator() ;it.hasNext();) {
Object[] objs=(Object[])it.next() ;
%>







暫無
















[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13428095/viewspace-1000842/,如需轉載,請註明出處,否則將追究法律責任。

相關文章