posts - 241,  comments - 116,  trackbacks - 0
          HQL查詢語句:from Course course where course.name like '%計算機%' 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 '%計算機%' order by course.date desc ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [where course.name like '%計算機%' order by course.date desc ]Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [where course.name like '%計算機%' 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……

          問題解決了:語句寫錯了!?。?br />
           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 }
          posted on 2008-12-02 20:28 墻頭草 閱讀(9935) 評論(0)  編輯  收藏 所屬分類: Spring
          人人游戲網 軟件開發網 貨運專家
          主站蜘蛛池模板: 克什克腾旗| 当涂县| 灌南县| 西平县| 绥德县| 涞水县| 瑞安市| 信阳市| 台湾省| 日喀则市| 长治县| 芜湖市| 呼伦贝尔市| 申扎县| 鹤山市| 邹平县| 凌源市| 安平县| 开阳县| 桦南县| 共和县| 江阴市| 黄龙县| 若羌县| 遂平县| 玛纳斯县| 双辽市| 罗田县| 航空| 内黄县| 巫溪县| 灵寿县| 前郭尔| 盐山县| 西盟| 东莞市| 澎湖县| 寻甸| 西宁市| 大英县| 垦利县|