# 페이징

## setFirstResult()

* 조회 시작 위치
  * 0부터 시작한다.
* setFirstResult(int startPosition)

## setMaxResults()

* 조회할 데이터 수
* setMaxResults(int maxResult)

```java
public class JpaMain {

    public static void main(String[] args) {
        List<Member> resultList = em
                // order by를 해봐야 페이징이 잘 되는지 확인할 수 있다.
                .createQuery("select m from Member m order by m.age desc", Member.class)
                .setFirstResult(1).setMaxResults(10).getResultList();
    }
}
```

![](/files/-MXMKd_4dS-87sUiBDAz)

* 위의 로그처럼 오라클이었다면 복잡했을 쿼리를 API를 통해 쉽게 적용할 수 있다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dodeon.gitbook.io/study/kimyounghan-orm-jpa/10-object-oriented-query/paging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
