我的存储库实现为:
public interface ItemRepository extends JpaRepository<Item,Long > { ...
在这里,我有一种方法:
Page<Item> findAllOrderByCreateDateDesc(PageRequest pageRequest);
我收到此错误:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property desc found for type ZonedDateTime! Traversed path:
但是,如果我将By添加为:
Page<Item> findAllByOrderByCreateDateDesc(PageRequest pageRequest);
我得到:
java.lang.IllegalArgumentException: At least 1 parameter(s) provided but only 0 parameter(s) present in query.
at org.springframework.util.Assert.isTrue(Assert.java:136)
好像我应该这样写:
findAllByOrderByCreateDateDesc
为什么会出现参数错误?我不想为此特定查询使用where子句。
答案 0 :(得分:1)
您必须在存储库方法中使用Pageable而不是PageRequest:
Page<Item> findAllByOrderByCreateDateDesc(Pageable pageable);