日期:2014-05-19 浏览次数:20716 次
List<Admin> list= this.getHibernateTemplate().find("from domain.Admin admin where admin.name =? and admin.password=?", admin.getName(),admin.getPassword());
public List find(final String queryString, final Object... values) throws DataAccessException { return executeWithNativeSession(new HibernateCallback<List>() { public List doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery(queryString); prepareQuery(queryObject); if (values != null) { for (int i = 0; i < values.length; i++) { queryObject.setParameter(i, values[i]); } } return queryObject.list(); } }); }