public void avg3(){
//使用DecimalFormat方法对Double数值进行格式化
DecimalFormat df=new DecimalFormat("0.00");
session=HibernateUtil.getSession();
//聚合函数
hql="select new entity.DeptSalary(e.dept.deptName,avg(e.sal)) from Emp e group by e.dept.deptName";
List<DeptSalary> dsList=session.createQuery(hql).list();
for(DeptSalary ds:dsList){
System.out.print(ds.getDeptName()+" : ");
System.out.print(df.format(ds.getSalary()));
System.out.println();
}
HibernateUtil.closeSession();
}