@Override /***通过姓名和月份查询工资***/ public UserInfo getUserByNM(String IDnum, String monthtime) { Writelog.writetolog("进来uerinfoDaoimpl!"); /*下面的hql语句from 应该直接就是po对象,不是数据库表名字 然后后面u.IDnum和u.salarymonth 也是po对象里面元素的名字**/ String hql= "from UserInfo u where u.IDnum=? and u.salarymonth=?"; Object[] values={IDnum,monthtime}; /**数组初始化 String[] str = {"1","2","3"}; // 正确的 string[] str = new String[]{"1","2","3"} // 也是正确的**/ List list=this.getHibernateTemplate().find(hql, values); if (list.size() >= 1) { Writelog.writetolog("list size >1!"); UserInfo userinfo = (UserInfo)list.get(0); return userinfo; } else {Writelog.writetolog("list size =0!"); return null; } }
时间: 2024-12-24 13:57:05