首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

net.sf.hibernate.QueryException: unexpected token: as [select c from courseinfo

2014-01-26 
我用hibernate  用findAll方法返回一个纪录集时出现的错误提示net.sf.hibernate.QueryException: unexpecte

我用hibernate  用findAll方法返回一个纪录集时出现的错误提示
  net.sf.hibernate.QueryException: unexpected token: as [select c from courseinfo as c]
  at net.sf.hibernate.hql.FromParser.token(FromParser.java:94)
  at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
  at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
  at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
  at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
  at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
  at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
  at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1554)
  at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1525)
  at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
  at net.zzyx.stuscore.dao.hibernate.HBCourseinfoDAO.findAll(HBCourseinfoDAO.java:96)
  at net.zzyx.stuscore.util.DBUtil.main(DBUtil.java:82)
  net.zzyx.stuscore.exception.FinderException: error.finder.wishes
  at net.zzyx.stuscore.dao.hibernate.HBCourseinfoDAO.findAll(HBCourseinfoDAO.java:99)
  at net.zzyx.stuscore.util.DBUtil.main(DBUtil.java:82)
  Exception in thread "main"

------解决方法--------------------------------------------------------
检查一下courseinfo对应的配置文件
------解决方法--------------------------------------------------------
select c from courseinfo as c
  改成select * from courseinfo试试。还有courseinfo里只有coursename和coursecode吗?这个表有没有相应的实体bean?
 
------解决方法--------------------------------------------------------
应该是:select c from Courseinfo as c
 
  Courseinfo是对象名,不是表名

        

热点排行