I've got a field called "count". And now I want to order my table by that field. As I know, COUNT
is reserved statement in Hibernate. Is there any approach to order table without renaming?
My code:
@Override
public List<Distribution> getListOrderByCount(String userName) {
List<Distribution> result = (List<Distribution>) sessionFactory
.getCurrentSession()
.createQuery(
"from Distribution where username=:userName ORDER BY count DESC")
.setString("userName", userName).list();
return result;
}