Hi,
I've got two models which have a one-to-many relationship. Lets say its an auction for a product and the product can have many bids.
Basically what I'd like to do is pull out all the products but order them by the number of bids they've received.
What I've got so far is:
"select p from Product as p join p.bids b where b.product=p order by COUNT(b) ASC";
However, this only seems to pull out one product with bids on it. If i want to order during a hibernate query I can normally do something like
"select p from Product as p ORDER BY p.name";
I thought I could just do something along the lines of
"select p from Product as p ORDER BY COUNT(p.bids)";
But I cannot.
Does anyone haev any advice or experience with a problem like this?
Thanks, -gearoid