-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL with subquery - QuerySyntaxException: unexpected token
PostPosted: Mon Mar 20, 2006 4:36 pm 
Newbie

Joined: Mon Mar 20, 2006 4:30 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.