import java.sql.SQLException;import java.util.List;import java.util.Map;import java.util.Map.Entry;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Session;import org.springframework.orm.hibernate3.HibernateCallback;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;public class SealDaoextends HibernateDaoSupport{ /** * description:hql获取list * @param hql * @param map * @return List * * */ public List getList(final String hql,final Map keyValue)throws Exception{ return getHibernateTemplate().execute(new HibernateCallback
>(){ @Override public List doInHibernate(Session session) throws HibernateException, SQLException { // TODO Auto-generated method stub Query query=session.createQuery(hql); for(Entry entry : keyValue.entrySet()){ query.setParameter(entry.getKey(),entry.getValue()); } return query.list(); } }); }}
写好hql,加入map参数,就可以查询泛型POJO列表