你执行的是非hql语句是SQL语句。hibernate怎么能实现转成list的对象呀?你说他list()一个是什么东西??什么样的List
public List test() {
Strng hql ="*****" //sql
Query query = session.createQuery(hql);
return query.list();
}
还是报错啊?很郁闷!
Session session = null;
try {
session = HibernateSessionFactory.getSession();
List list = session.createSQLQuery("select * from user_role ur join privilege p where ur.iUser_Id=3 and p.vAbility_Name='010501' and ur.iRole_Id=p.iRole_Id").list();
System.out.println(list);
} catch (HibernateException e) {
e.printStackTrace();
}
public List*这里是你查的表所对应的类*/> sqlConnect(){
Strng hql ="*****" //hql 是你hibernate逆向工程出来的类作为根据写的 结构类似SQL语句
Query query = session.createSQLQuery(hql);
List*这里是你查的表所对应的类*/> list = HebernateFactorySession.getSession().executeQuery(hql).list();
return list;
}