Exception:hibernate HQL不充分支持 case when语句?
来源:互联网 发布:怎样恢复优盘数据恢复 编辑:程序博客网 时间:2024/05/16 08:08
这两天写代码时又碰到这个问题,放到从前就直接改成用SQL了,但是这次比较特殊,不想浪费时间做太多修改,
在网上搜索了很久,各个方法都试了试,还是没有解决,郁闷
不能再浪费时间了,就索性一咬牙改成了SQL,
mark于此,希望有空时有高人能解决
sql.append("select ts,te.teacherName" +
",case ts.labId when 0 then '无' else (select lb.labName from LabBase lb where lb.labId=ts.labId) end as A4" +
",case ts.collegeCode when '00' then '无' else (select co.collegeName from College co where co.collegeCode=ts.collegeCode) end as A5" +
",te.isLock,te.teacherNumber,ts.labId " +
"from TeaStatistics ts,Teacher te where ts.teacherId=te.teacherId ");
就这样就报错了
ERROR 2012 四月 04 10:39:35,216org.hibernate.hql.PARSER (org.hibernate.hql.ast.ErrorCounter.reportError(ErrorCounter.java:56)) - <AST>:0:0: unexpected AST node: query
ERROR 2012 四月 04 10:39:35,217org.hibernate.hql.PARSER (org.hibernate.hql.ast.ErrorCounter.reportError(ErrorCounter.java:56)) - <AST>:0:0: unexpected AST node: query
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: query [select ts,te.teacherName,case ts.labId when 0 then '无' else (select lb.labName from entityAndDAO.LabBase lb where lb.labId=ts.labId) end as A4,case ts.collegeCode when '00' then '无' else (select co.collegeName from entityAndDAO.College co where co.collegeCode=ts.collegeCode) end as A5,te.isLock,te.teacherNumber,ts.labId from entityAndDAO.TeaStatistics ts,entityAndDAO.Teacher te where ts.teacherId=te.teacherId and ts.termYear ='2011-2012' ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
at com.lab.action.TeacherAction.listYear(TeacherAction.java:714)
在网上搜索了很久,各个方法都试了试,还是没有解决,郁闷
不能再浪费时间了,就索性一咬牙改成了SQL,
mark于此,希望有空时有高人能解决
sql.append("select ts,te.teacherName" +
",case ts.labId when 0 then '无' else (select lb.labName from LabBase lb where lb.labId=ts.labId) end as A4" +
",case ts.collegeCode when '00' then '无' else (select co.collegeName from College co where co.collegeCode=ts.collegeCode) end as A5" +
",te.isLock,te.teacherNumber,ts.labId " +
"from TeaStatistics ts,Teacher te where ts.teacherId=te.teacherId ");
就这样就报错了
ERROR 2012 四月 04 10:39:35,216org.hibernate.hql.PARSER (org.hibernate.hql.ast.ErrorCounter.reportError(ErrorCounter.java:56)) - <AST>:0:0: unexpected AST node: query
ERROR 2012 四月 04 10:39:35,217org.hibernate.hql.PARSER (org.hibernate.hql.ast.ErrorCounter.reportError(ErrorCounter.java:56)) - <AST>:0:0: unexpected AST node: query
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: query [select ts,te.teacherName,case ts.labId when 0 then '无' else (select lb.labName from entityAndDAO.LabBase lb where lb.labId=ts.labId) end as A4,case ts.collegeCode when '00' then '无' else (select co.collegeName from entityAndDAO.College co where co.collegeCode=ts.collegeCode) end as A5,te.isLock,te.teacherNumber,ts.labId from entityAndDAO.TeaStatistics ts,entityAndDAO.Teacher te where ts.teacherId=te.teacherId and ts.termYear ='2011-2012' ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
at com.lab.action.TeacherAction.listYear(TeacherAction.java:714)
- Exception:hibernate HQL不充分支持 case when语句?
- Exception:hibernate HQL不充分支持 case when语句?
- HQL中使用case when
- Case when 支持变量
- case when 语句
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- sql语句 case when
- mysql 语句case when
- MySQL CASE WHEN语句
- mysql 语句case when
- Sql语句:case when
- case...when语句使用
- oralce case when 语句
- redis 在PHP中的应用 代码实例
- Generating SSH Keys
- 函数形参作用域为整个函数体
- 十一月中旬,夜,蚊帐内,蚊子,嘴唇,小香肠似的嘴唇...
- easyUI 中用来判断表单时否通过验证
- Exception:hibernate HQL不充分支持 case when语句?
- 论数字图书的理论化(7)
- 20步打造完美网站布局设计
- 自动获取和创建XML文件的表列到DataGridView显示和编辑
- android 处理图片之--bitmap处理
- SGU107——987654321 problem
- 第十三周上机实践项目——fibnacci序列(迭代法)
- Python串口编程(转载)
- [Android NDK] Android NDK可能遇到的问题