问题
I have this query. Translate it from my sql query to hql. I have this error "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();
I don't underastand what'w wrong
回答1:
My bad Vytsalo, didnt look at the databse tag. HQL subqueries is not supported on from clauses
Note that HQL subqueries can occur only in the select or where clauses:Hibernate Query Language
来源:https://stackoverflow.com/questions/59925853/hql-unexpected-token-subquery-select