我有这段代码,但是当我运行它时出现错误,我也使用本机查询来执行此操作,但我徒劳无功
EntityManager entityManager = Persistence.createEntityManagerFactory("AdvancedJavaProjectPU").createEntityManager();
entityManager.getTransaction().begin();
Query query = entityManager.createQuery("Select e FROM Question e ORDER BY RAND()").setMaxResults(20);
List<Question> question =query.getResultList();
for(Question q:question){
System.out.println(q.getName());
}
我收到此错误:-
异常描述:语法错误解析查询 [Select e FROM Question e ORDER BY RAND()],第 1 行,第 38 列:意外标记 [(]。