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……

问题解决了:语句写错了!!:
 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 墙头草 阅读(9903) 评论(0)  编辑  收藏 所属分类: Spring

只有注册用户登录后才能发表评论。


网站导航:
 
人人游戏网 软件开发网 货运专家