hibernate HQL查询返回map

public DataModel getTblReportVhostsHistoryHbnPage(final String countHQL,final String queryHQL,final NavRequest pNavRequest,final List list) throws DataAccessException {
// TODO Auto-generated method stub
return (DataModel)getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException,SQLException {
       Query countQuery = s.createQuery(countHQL);
       for(int i=0;i<list.size();i++)
       countQuery.setParameter(i, list.get(i));
       Integer count = ((Long)countQuery.uniqueResult()).intValue();
       Query query = s.createQuery(queryHQL).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
       query.setFirstResult(pNavRequest.getStart());
       query.setMaxResults(pNavRequest.getPageSize());
       for(int i=0;i<list.size();i++)
       query.setParameter(i, list.get(i));
             DataModelCreator creator = new HibernateDataModelCreator(count.intValue(), query);
        return creator.create(pNavRequest);
}        
        });
}
版本为hibernate3.2
主要方法是 Query query = s.createQuery(queryHQL).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

你可能感兴趣的:(Hibernate)