public List<Object[]> queryAll(){
List list = (List) getSession().createSQLQuery("SELECT * FROM TEST")
.addScalar("ID", Hibernate.LONG)
.addScalar("GOODS_NAME", Hibernate.STRING)
.list();
return list;
} //指定返回两列
List<Object[]> list =dao.queryAll();
for (int i = 0; i < list.size(); i++) {
List<Object []> li = new ArrayList();
li.add(list.get(i));
for (Object[] o : li) {
System.out.println("ID"+o[0]+"\t GOODS_NAME:"+o[1]);
}
}
遍历hibernate 原生查询返回List<Object[]>
最新推荐文章于 2020-11-18 14:34:35 发布