List list = this.getHibernateTemplate().find(hql, empNo);
if(list != null && list.size() > 0) {
employee = (TEmployee) list.get(0);
}else{
employee = null;
}
或:
try {
List list = this.getHibernateTemplate().find(hql, empNo);
employee = (TEmployee) list.get(0);
} catch (Exception e) {
e.printStackTrace();
return null;
}