日期:2014-05-19 浏览次数:20895 次
public List<T> findEntity(final String hql,
final Map<String,Object> parmap, final boolean cache)
throws Exception {
return (List<T>) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery(hql);
if(parmap!=null){
Iterator iter=parmap.entrySet().iterator();
while(iter.hasNext()){
Map.Entry e=(Map.Entry)iter.next();
query.setParameter(e.getKey().toString(), e.getValue());
}
}
//写入缓存
query.setCacheable(cache);
return query.list();
}
});
}