String query = "select {profile_.*}, count(message.userID) as i from Forum forum_ inner join ForumMessage message on message.forumID=forum_.forumID "
+ " inner join profile {profile_} on message.userID={profile_}.id"
+ " group by message.userID order by i desc ";
I use the statement :
Query hibernateQuery = session.createSQLQuery(query, "profile_", Profile.class);
to execute the query, cause it seems I can not give an alias to count(...) value in HQL?
There are domain objects : Profile, Forum, ForumMessage,and I want to get user profiles order by their posted messages count.
Thanks.
|