-->
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.  [ 8 posts ] 
Author Message
 Post subject: Fata bug in hibernate in 3.1RC2 and hibernate3.0.5.
PostPosted: Mon Nov 07, 2005 8:49 pm 
Newbie

Joined: Fri Jun 24, 2005 6:26 am
Posts: 1
HQL clause:

"select message.forumID, count(*) as mmm from "+ ForumMessage.class.getName()+
" message group by message.forumID order by mmm DESC"

Translated sql clause:

Hibernate: select forummessa0_.forumID as col_0_0_, count(*) as col_1_0_ from ForumMessage forummessa0_ group by forummessa0_.forumID order by mmm DESC limit ?

Eorror reported:

JDBCExceptionReporter [ERROR] Unknown column 'mmm' in 'order clause'

Tested under :mysql 4.1 ,msslql 2000,hibernate3.1rc2,hibernate3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 9:38 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You want an sql-query, not a query. Query is used for mapping to a class, not a pair of integers. I believe that you can use a plain old query for this, but I never bothered to look up how, as sql-query does it very well.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 9:40 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
i try with oracle and i think that this is bug in hql


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 10:04 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
HQL does not have an "as" keyword in the select clause. This is not valid HQL. Use SQL if you want SQL. Stop posting "bug in Foo" if you don't understand something.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 11:39 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
hql would be return error and not wrong sql if it doesn't support - this confuse users

for example :

select model.id,count(*) as mmm
from MyClass as model
group by model.id
order by model.mmm

return error (don't generate and try execute sql)

select model.id,count(*) as mmm
from MyClass as model
group by model.id
order by mmm

generate and execute wrong sql

select model.id,count(*)
from MyClass as model
group by model.id
order by mmm

generate and execute wrong sql

workaround for this query (this work)

select model.id,count(*) as mmm
from MyClass as model
group by model.id
order by 2

(i suppose that id isn;t component type or composite id)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 11:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
When can you have the patch ready?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 11:45 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Repeat: This isn't a bug. HQL passes on everything it doesn't know in the ORDER BY. It could be a native SQL function. If you want alias support, submit a patch to the grammar.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 12:38 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
HQL passes on everything it doesn't know in the ORDER BY.


this isn't correct
hql find error in order by for this case

select model.id,count(*)
from MyClass as model
group by model.id
order by model.mmm

and throw exception QueryException
org.hibernate.QueryException: could not resolve property: mmm of: myClass [select model.id,count(*) from MyClass model group by model.id order by model.mmm]

ok.it isn't bug, than missing features
'order by' can have - same like select list + positional parameters and hql can recognize it easy

i agree that it isn't important (workaround exists) , but it would be nice


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

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.