我在我的存儲庫中使用查詢,我試圖從表中選擇10個隨機問題。但我得到這個錯誤 ASC或DESC預期得到了「(」 ,我不知道爲什麼按隨機順序選擇()查詢不工作在Java
@Query (value = "select q from Question q where q.chapitre_id=:id order by
random() limit 10", nativeQuery = true)
List<Question> findQuestionsByChapitre(@Param("id") Long id);
嘗試蘭特(),而不是隨機的() –
沒有工作或者 –
你不應該使用'限10'這裏像'Oracle'不支持幾個數據庫儘管許多支持。我建議你嘗試使用'Page'和'Pageable'接口 – harshavmb