Notice
Recent Posts
Recent Comments
Link
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

개발자되기 프로젝트

페이징 본문

인프런/[인프런] QueryDsl

페이징

Seung__ 2021. 9. 1. 23:35

1. 예제


  • offset : 몇 개 건너뒴?
  • limit : 몇 개 씩?
 @Test
    public void paging1(){
        List<Member> result = queryFactory
                .selectFrom(member)
                .orderBy(member.username.desc())
                .offset(1)
                .limit(2) //2개씩
                .fetch();

        assertThat(result.size()).isEqualTo(2);
    }
  • fetchResults()를 통해 페이징 정보 포함.
  @Test
    public void paging2(){
        QueryResults<Member> queryResults = queryFactory
                .selectFrom(member)
                .orderBy(member.username.desc())
                .offset(1)
                .limit(2) //2개씩
                .fetchResults();

       assertThat(queryResults.getTotal()).isEqualTo(4);
       assertThat(queryResults.getLimit()).isEqualTo(2);
       assertThat(queryResults.getOffset()).isEqualTo(1);
       assertThat(queryResults.getResults().size()).isEqualTo(2);

    }

 

2. GitHub : 210901 Paging


 

GitHub - bsh6463/Querydsl

Contribute to bsh6463/Querydsl development by creating an account on GitHub.

github.com

 

'인프런 > [인프런] QueryDsl' 카테고리의 다른 글

Join  (0) 2021.09.02
집합  (0) 2021.09.01
정렬  (0) 2021.09.01
결과 조회  (0) 2021.09.01
검색조건 쿼리  (0) 2021.09.01
Comments