Pageable and @Param in a spring data JpaRepository method issue [2]

I encountered the same exception when I accidentally imported the wrong Pageable class.

This can also happen if you use PageRequest in the repository as well.

it should be,

import org.springframework.data.domain.Pageable;

Make sure you use Pageable instead of PageRequest so that the first parameter is recognized as one not to be bound to the actual query. Also, you need to change the return type to either Page or List as you'll return multiple results mostly.

public interface BalanceHistoryRepository extends CrudRepository<BalanceHistory, Long> {

  @Query("select bh from BalanceHistory bh where bh.account.id = :idAccount")
  Page<BalanceHistory> findCurrentBalanceByAccountNumber(@Param("idAccount") long idAccount, Pageable pageable);
}

This should do the trick. Note, that we generally recommend not to extend the store specific interfaces as they expose store-specific API that should only be exposed if really necessary.