hibernate多表查询sql,以及所得对象的处理

String sql ="SELECT id FROM tea WHERE tea.name=? ";
SQLQuery query = this.getSession().createSQLQuery(sql);

//设置参数
Query q = query.setParameter(0, teachers[0]);
List list = q.list();
Iterator iterator = list.iterator();
while(iterator.hasNext()){
Integer id = (Integer) iterator.next();
}
}

posted @ 2018-06-06 13:17  锋_锋  阅读(458)  评论(0编辑  收藏  举报