-->
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.  [ 4 posts ] 
Author Message
 Post subject: question on example in hibernate
PostPosted: Tue May 25, 2004 4:04 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
I have tried the example in hibernate.
Now I want get a list of AuctionItem what be sorted by the elements in AuctionItem.bids, How can I write this HQL???


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:51 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
By reading documentation... first


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:07 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
:(

I have tried so many times.

I created a HQL like this:
Code:
select auctionitem
from AuctionItem as auctionitem
left join auctionitem.bids as bid
group by auctionitem
order by count(bid)


the sql created by hibernate is
Code:
select auctionite0_.id as id, auctionite0_.description as descript2_, auctionite0_.ends as ends, auctionite0_.condition as condition, auctionite0_.seller as seller, auctionite0_.successfulBid as successf6_
from AuctionItem auctionite0_ left outer join Bid bids1_ on auctionite0_.id=bids1_.item
group by  auctionite0_.id
order by  count(bids1_.id)


but get a excetiop
Code:
Invalid use of group function


I use MySQL database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:15 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
If you do count(bids) all other colums should be in your group by clause.

You have to explicitly use all your colums in the group by. Only placing your AuctionItem object only gives the id column.

So change the group by with group by AuctionItem.id, Auctionitem.description, ...


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