-->
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: Version property disturbs a query with a group by
PostPosted: Mon Sep 27, 2004 11:02 am 
Newbie

Joined: Tue Aug 31, 2004 7:11 am
Posts: 2
Location: Israel
Hibernate version:2.1

Full stack trace of any exception that occurs:
16:40:37,269 WARN [JDBCExceptionReporter] SQL Error: 979, SQLState: 42000
16:40:37,276 ERROR [JDBCExceptionReporter] ORA-00979: not a GROUP BY expression

Name and version of the database you are using:Oracle 10g

The generated SQL (show_sql=true):
Code:
select host0_.id as id, host0__1_.ver as ver7_ from host host0_
    inner join core_entity host0__1_ on host0_.id=host0__1_.id
    inner join address addresses1_ on host0_.id=addresses1_.host_id
group by  host0_.id
order by  min(addresses1_.ip) asc


Hi Hibernate folks.

I have issued a query that looks like this:

Code:
select host
from Host host
   join host.addresses addr
group by host
order by min(addr.ip) asc


I did not add my noisy map files since the case is almost identical to the example HQL shown in Hibernate reference section 11.10:

Code:
select cat
from eg.Cat cat
    join cat.kittens kitten
group by cat
having avg(kitten.weight) > 100
order by count(kitten) asc, sum(kitten.weight) desc


as one can see the generated sql is erronous because the version appears in the select but not in the group by.

The way to workaround this is to add the version to the HQL:

Code:
select host
from Host host
   join host.addresses addr
group by host, host.version
order by min(addr.ip) asc


It seems logical to me that the version property should be transparent to the HQL writer.
Am I missing something ?


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.