我用本地sql查询怎么不行啊?老报错
这是错误:
hibernate.QueryException: unexpected char: '{' [select {vw.*} from vw_ele_ask vw where vw.stuId='X1203001' union select {vw.*} from vw_ele_ask vw where vw.couId not in(select vw.couId from vw_ele_ask vw where vw.stuId='X1203001')group by vw.couId;]
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:204)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
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:1623)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:839)
这是查询语句:
hql="select {vw.*} from vw_ele_ask vw " +
"where vw.stuId='X1203001' union" +
" select {vw.*} from vw_ele_ask vw" +
" where vw.couId not in(select vw.couId from vw_ele_ask vw " +
"where vw.stuId='X1203001')group by vw.couId";
------解决方案--------------------
都是使用HQL了,这个查询语句还这么复杂!