浏览 205 次
|
该帖已经被评为新手帖
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2008-05-20 关键字: hebernate——query.setproperties(map map)
daoService里的方法:
@SuppressWarnings("unchecked") public <T> Collection<T> findByHQLNative(String hql, Map<String, Object> params, int begin, int count) throws DataAccessException { Collection<T> list = null; try { Session sess = sessionFactory.getCurrentSession(); Query query = sess.createQuery(hql); if (begin >= 0) query.setFirstResult(begin); if (count >= 0) query.setMaxResults(count); if (params != null && params.size() > 0) { query.setProperties(params); } list = query.list(); } catch (HibernateException e) { log.error("HibernateException--", e); throw SessionFactoryUtils.convertHibernateAccessException(e); } return list; } 在Action里调用如下: String hql="select s from src.main.operation.model.Student s where s.id= :id"; Map<String,Object> map= new HashMap<String, Object>(); map.put("id", id); Collection<Student> s=daoService.findByHQLNative(hql, map,-1,-1); //我如上调用findByHQLNative方法是会出 Not all named parameters have been set: [id]的异常 我的Hibernate版本是3.2的 支持setProperties(Map map)的方法的 这是怎么回事呢? --| 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |


