隨筆-42  評(píng)論-349  文章-4  trackbacks-0

          HQL查詢語(yǔ)句:from Course course where course.name like '%計(jì)算機(jī)%' order by course.date desc  異常:

          [org.hibernate.hql.PARSER] - <AST>:0:0: unexpected end of subtree 2008-05-06
          18:36:04,062 ERROR [org.hibernate.hql.PARSER] -  Invalid path: 'course.name'
          2008-05-06 18:36:04,062 ERROR [org.hibernate.hql.PARSER] - <AST>:0:0: unexpected end of subtree
          2008-05-06 18:36:04,062 ERROR [org.hibernate.hql.PARSER] -  left-hand operand of a binary operator was null
          2008-05-06 18:36:04,093 ERROR [org.hibernate.hql.PARSER] -  Invalid path: 'course.date'
          2008-05-06 18:36:04,125 ERROR [com.vod.dao.CourseDAO] - find all failed org.springframework.orm.hibernate3.HibernateQueryException: unexpected end of subtree [where course.name like '%計(jì)算機(jī)%' order by course.date desc ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [where course.name like '%計(jì)算機(jī)%' order by course.date desc ]Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [where course.name like '%計(jì)算機(jī)%' order by course.date desc ] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at
          org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:225) at
          org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158) at
          org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109) at
          org.hibernate.engine.query.HQLQueryPlan.<init>
          (HQLQueryPlan.java:75) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:15……

          問題解決了:語(yǔ)句寫錯(cuò)了!!:
           1   public List findByHql(String hql){    
           2         log.debug("finding all Course instances");     
           3         try {
           4            String queryString = "from Course course " +hql+" ";
           5            System.out.println("\n\n"+queryString+"\n\n");
           6            return getHibernateTemplate().find(queryString);
           7         } catch (RuntimeException re) {
           8            log.error("find all failed", re);
           9            throw re;
          10         } 
          11 }

          寫成了:
           1 public List findByHql(String hql){
           2      log.debug("finding all Course instances");
           3      try {
           4          String queryString = "from Course course " +hql+" ";
           5          System.out.println("\n\n"+queryString+"\n\n");
           6          return getHibernateTemplate().find(hql);//就這里!真是郁悶
           7       } catch (RuntimeException re) {
           8          log.error("find all failed", re);
           9          throw re;
          10       } 
          11 }




          By:殘夢(mèng)追月
          posted on 2008-07-09 22:18 殘夢(mèng)追月 閱讀(11317) 評(píng)論(1)  編輯  收藏 所屬分類: Spring

          評(píng)論:
          # re: Hibernate unexpected end of subtree異常解決辦法 2012-12-29 12:56 | hql是什么
          hql是什么,這個(gè)問題就這么解決了?  回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 阿拉善左旗| 麟游县| 苏尼特左旗| 荆门市| 大名县| 永和县| 古田县| 江门市| 定陶县| 盖州市| 宁强县| 黄梅县| 合山市| 呼玛县| 九龙城区| 贵港市| 密云县| 临潭县| 绥滨县| 独山县| 博野县| 安龙县| 怀来县| 商水县| 陇川县| 北辰区| 禹州市| 合水县| 时尚| 平泉县| 富锦市| 开封县| 临沂市| 鄄城县| 东安县| 太仓市| 平顺县| 勐海县| 通山县| 门头沟区| 贺兰县|