Hello,
I am using Hibernate 3.1.
I have an Oracle 9i table MY_DOWNLOAD (id, filename) which is mapped by a hibernate xml-file to an Java-Bean „ThisDownload“.
The class “ThisDownload” has getters and setters for “id” and “filename” and is working fine when I query for instance “from ThisDownload”.
But now I have the following query with an included subquery:
from ThisDownload A
(
select max(id), filename
from ThisDownload
group by filename
) B
where A.id = B.id
and A.filename = B.filename
By running this query I get the following exception:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near
line 1, column 45 [ from ThisDownload A ( select max(id), filename
from ThisDownload group by filename ) B where A.id = B.id and
A.filename = B.filename]
at
org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at
org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:240)
at
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:151)
at
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:101)
at
org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:473)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1032)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:982)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
...
What’s wrong with this statement.
In the documentation is written that subqueries should be no problem.
Can somebody help?
Greetings
Snoop
|