hibernate执行sql语句错误
sql语句:selecta.recDt,a.nowValue,b.nowValuefrom(selectnowValue,recDtfromreg_conditionwh...
sql语句:select a.recDt,a.nowValue,b.nowValue from (select nowValue,recDt from reg_condition where regId=11 and recDt between '2012-08-20 14:08:40.0' and now()) a left join (select nowValue,recDt from reg_condition where regId=12 and recDt between '2012-08-20 14:08:40.0' and now()) b on a.recDt=b.recDt order by a.recDt desc
报错信息:
Struts Problem Report
Struts has detected an unhandled exception:
Messages:unexpected token: ( near line 1, column 44 [select a.recDt,a.nowValue,b.nowValue from ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=11 and recDt between '2012-08-20 14:08:40.0' and now()) a left join ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=12 and recDt between '2012-08-20 14:08:40.0' and now()) b on a.recDt=b.recDt order by a.recDt desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 44 [select a.recDt,a.nowValue,b.nowValue from ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=11 and recDt between '2012-08-20 14:08:40.0' and now()) a left join ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=12 and recDt between '2012-08-20 14:08:40.0' and now()) b on a.recDt=b.recDt order by a.recDt desc]File:org/hibernate/hql/ast/QuerySyntaxException.javaLine number:54
联合查询的,sql语句在Mysql里运行完全正常,用hibernate执行就异常了,异常处为第一个from。。求大神解答。 展开
报错信息:
Struts Problem Report
Struts has detected an unhandled exception:
Messages:unexpected token: ( near line 1, column 44 [select a.recDt,a.nowValue,b.nowValue from ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=11 and recDt between '2012-08-20 14:08:40.0' and now()) a left join ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=12 and recDt between '2012-08-20 14:08:40.0' and now()) b on a.recDt=b.recDt order by a.recDt desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 44 [select a.recDt,a.nowValue,b.nowValue from ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=11 and recDt between '2012-08-20 14:08:40.0' and now()) a left join ( select nowValue,recDt from com.bhit.lubrioil.bhh.RegCondition where reg.id=12 and recDt between '2012-08-20 14:08:40.0' and now()) b on a.recDt=b.recDt order by a.recDt desc]File:org/hibernate/hql/ast/QuerySyntaxException.javaLine number:54
联合查询的,sql语句在Mysql里运行完全正常,用hibernate执行就异常了,异常处为第一个from。。求大神解答。 展开
4个回答
展开全部
貌似from 后面一般是跟domain类名,而且首字母大写,反正这样的查询我没用过,hibernate就是简化查询语句的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序里面的语句是hql语句,里面不写表名,应该写反转生成的类名。
追问
你仔细看看报错信息里面我是怎么写的,上面的sql是另外换算过的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询