-->
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.  [ 5 posts ] 
Author Message
 Post subject: question of the example in hibernate2.1.3
PostPosted: Tue May 04, 2004 9:02 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
I have run the example "Auction" which is in the 2.1.3

I want query the list of users that order by the elements os User.bids


I create HQL

Code:
select user from User as user
left join user.bids as bid
group by user
order by count(bid)


the SQL created by Hibernate is


Code:
select user0_.id as id, user0_.userName as userName, user0_.`password` as y3_, user0_.email as email, user0_.firstName as firstName, user0_.`initial` as y6_, user0_.lastName as lastName from AuctionUser user0_ left outer join Bid bids1_ on user0_.id=bids1_.bidder group by  user0_.id order by  count(bids1_.id)


but it caught a exception
Code:
21:02:03,765 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: General error,  message from server: "Invalid use of group function"



what wrong with it????
I use MySQL 3.23.58


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 9:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you have to explicitly call all properties with group by clause
group by user.id, user.xx, ....


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 9:09 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
I have tried it, but got the same exception


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 9:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
humm it works...

http://www.hibernate.org/74.html#A14


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 9:16 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
I have tried every thing, :(

can you write the correct HQL for me? thanks a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.