HQL 意外标记“(”子查询 select
HQL unexpected token "(" subquery select
我有这个问题。将它从我的 sql 查询翻译成 hql。我有这个错误
"unexpected token: ( near line 2, column"
String query = "SELECT MAX(number)\n" +
" FROM (SELECT number FROM EmployeeTripCard \n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" UNION ALL\n" +
" SELECT trip_card_number FROM PostgraduateTripCard\n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" UNION ALL\n" +
" SELECT trip_card_number FROM StudentTripCard \n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" )";
Integer result = (Integer) getSessionFactory().getCurrentSession().createQuery(query).uniqueResult();
我不明白哪里出了问题
我的坏 Votsalo,没看数据库标签。
from 子句不支持 HQL 子查询
请注意,HQL 子查询只能出现在 select 或 where 子句中:Hibernate Query Language
我有这个问题。将它从我的 sql 查询翻译成 hql。我有这个错误 "unexpected token: ( near line 2, column"
String query = "SELECT MAX(number)\n" +
" FROM (SELECT number FROM EmployeeTripCard \n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" UNION ALL\n" +
" SELECT trip_card_number FROM PostgraduateTripCard\n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" UNION ALL\n" +
" SELECT trip_card_number FROM StudentTripCard \n" +
" WHERE EXTRACT(YEAR FROM issueDate) = '2015'\n" +
" )";
Integer result = (Integer) getSessionFactory().getCurrentSession().createQuery(query).uniqueResult();
我不明白哪里出了问题
我的坏 Votsalo,没看数据库标签。 from 子句不支持 HQL 子查询
请注意,HQL 子查询只能出现在 select 或 where 子句中:Hibernate Query Language