hql="from AskBuy as a where a.userID = ? order by ? desc ";
Query query=session.createQuery(hql);
query.setParameter(0, userId);
query.setParameter(1,time);
query.setMaxResults(5);
查询出来 排序无效. 纠结好久都没法解决,最后用拼字符串,改成
hql="from AskBuy as a where a.userID = ? order by time desc ";
Query query=session.createQuery(hql);
query.setParameter(0, userId);
query.setMaxResults(5);
这样就可以,不知为何,待探索