public interface StudentDAO extends JpaRepository<StudentEntity, Integer> {
public List<StudentEntity> findAllByOrderByIdAsc();
}
上面的代码应该可以工作。我正在使用类似的东西:
public List<Pilot> findTop10ByOrderByLevelDesc();
它返回最高级别的10行。
重要提示: 由于有人告诉我很容易错过此答案的关键点,因此需要澄清一下:
findAllByOrderByIdAsc(); // don't miss "by"