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