可分页和@Param在弹簧数据JpaRepository方法问题[2]
2022-09-04 07:12:40
我知道这个问题,但使用我仍然遇到同样的问题()。我的班级是:org.springframework.data:spring-data-jpa:1.7.0.RELEASE
Either use @Param on all parameters except Pageable and Sort typed once, or none at all!
public interface BalanceHistoryRepository extends JpaRepository<BalanceHistory, Long> {
@Query("select bh from BalanceHistory bh where bh.account.id = :idAccount")
public BalanceHistory findCurrentBalanceByAccountNumber(PageRequest pageCriteira, @Param("idAccount") long idAccount);
}
编辑
叫:
Pageable page = new PageRequest(0, 1, Sort.Direction.DESC, "date");
BalanceHistory bh = balanceHistoryRepository.findCurrentBalanceByAccountNumber(1,page);
方法:
@Query("select bh from BalanceHistory bh where bh.account.id = :idAccount")
public BalanceHistory findCurrentBalanceByAccountNumber(@Param("idAccount") long idAccount, Pageable pageCriteira);