我的函数如下:
public List getSorts() throws HibernateException {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
List list=null;
try {
Query query = session.createQuery("from Sort"); //鍒涘缓鏌ヨ瀵硅薄
list = query.list();
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
}
HibernateUtil.closeSession();
return list;
}
我在调用的时候出现这样的问题:
org.hibernate.exception.SQLGrammarException: could not execute query
请教高手怎么回事,分不多,请帮帮小弟了!谢谢!!
public List getSorts() throws HibernateException {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
List list=null;
try {
Query query = session.createQuery("from Sort"); //鍒涘缓鏌ヨ瀵硅薄
list = query.list();
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
}
HibernateUtil.closeSession();
return list;
}
我在调用的时候出现这样的问题:
org.hibernate.exception.SQLGrammarException: could not execute query
请教高手怎么回事,分不多,请帮帮小弟了!谢谢!!
2、检查你的Sort.java有没有在hibernate.cfg.xml文件里面进行映射
另外,查询是不需要commit提交事务的。
检查你HIBERNATE配置文件Sort对应关系
可能是映射的不对吧..不知道你用的hibernate的版本是多少..在Sort后面加个别名as s试下.