随机查询数据


return evaluationMemberDao.createCriteria().add(Expression.sql("1=1 order by rand()")).setMaxResults(num).list();

 

 

String hql = " from EvaluationExpert e order by rand() ";// use newid() instead of rand() if you use MS SQLServer as DB

return evaluationExpertDao.createQuery(hql).setMaxResults(num).list();

你可能感兴趣的:(sql)