我已经在存储库文件中开发了本机查询
@RepositoryRestResource
public interface PersonRepository extends CrudRepository<Person, Long>
public List<Person> findDistinctByStatus(Pageable pageable);
@Query(value="SELECT distinct 1 as id, i.person_id, a.age from TableA a inner join tableB i on a.person_id= i.person_id
where a.status="NotCool" and i.status_id=2 ",
countQuery = "SELECT count(a.person_id) from TableA a
inner join tableB i on a.person_id= i.person_id
where a.status="NotCool" and i.status_id=2 "
,
nativeQuery=true)
public List<Person> findDistinctByStatus(Pageable pageable);
我也尝试过
public Page<Person> findDistinctByStatus(Pageable pageable);
Pageable pageable = PageRequest.of(page, sizeLimit, direction, sortingParam);
我尝试了各种组合
page = 0;大小= 5,
page = 1;尺寸= 10
等
但是我得到了错误的数据,
总共有14条记录,但是我总是多次获得相同的记录。当我尝试page = 0和size = 5时,我得到1条记录,是size = 10的5倍。
我唯一获得正确数据的时间是当我设置page = 1和size = 1时。
我做错了什么?
请帮助我已经为此花费了太多时间。我无处可寻。