81,120
社区成员
发帖
与我相关
我的任务
分享
//使用addScalar方法将查询结果转换成标量值
Query query = session.createSQLQuery(sqlQuery)
.addScalar("wdjdmc", org.hibernate.Hibernate.STRING)
.addScalar("wdbm", org.hibernate.Hibernate.STRING)
.addScalar("sbsj",org.hibernate.Hibernate.TIMESTAMP)
.addScalar("hqsj", org.hibernate.Hibernate.TIMESTAMP)
.setResultTransformer(Transformers.aliasToBean(ReportGrid.class));
// Query query = session.createSQLQuery(sqlQuery);
//将所查出来的数据设置为hashMap类型
query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<ReportGrid> lt = (List<ReportGrid>)query.list();