In hibernate I have a table/class Question and a table/class Vote. Vote.questionId is a foreign key for Question.id.
I want to sort the question by the number of votes.
I am executing
session.createQuery("from Question q, Vote v where q.id = v.questionId group by q.id order by count(v) desc")
But I get “could not execute query”
If you’re using groups you’ll need to select fields specifically just like in SQL, so your query will look like:
cheers!