티스토리 뷰
스프링 부트 2.6 버전 이상부터 Querydsl 5.0을 기본으로 지원하게 되면서 몇 가지 주의해야할 사항들이 있습니다.
PageableExecutionUtils 패키지 변경
먼저 PageableExecutionUtils의 패키지 위치가 변경되었습니다.
기존 위치는 org.springframework.data.repository.support.PageableExecutionUtils였는데 org.springframework.data.support.PageableExecutionUtils로 변경되었습니다.
기존에 사용하고 있었다고 하면 import를 다시 해주셔야 합니다.
Querydsl fetchResults(), fetchCount() Deprecated
Querydsl의 fetchCount()와 fetchResult()는 select 쿼리를 기반으로 count 쿼리를 내부에서 만들어서 실행하는데, 이 기능 자체는 단순히 select로 count를 처리하는 용도였습니다.
따라서 단순한 쿼리에서는 정상동작하였지만 쿼리가 조금만 복잡해져도 기대한 결과를 얻기 어려웠습니다.
그래서 해당 기능들은 모두 deprecated 되었습니다.
하지만 deprecated이기 때문에 아직은(?) 정상 동작하는 코드를 수정할 필요는 없습니다만 warning이 많이 거슬리시는 분들은 아래 처럼 count 쿼리를 수정해주셔야 합니다.
select count(member.id) from member
Long totalCount = queryFactory
.select(member.count())
.from(member)
.fetchOne();
select count(*) from member
Long totalCount = queryFactory
.select(Wildcard.count)
.from(member)
.fetchOne();
이런식으로 사용 가능하고 count의 결과가 한 개이기 때문에 fetchOne()을 사용해야 합니다.
'Querydsl' 카테고리의 다른 글
| 스프링부트 2.6 이상 버전에서 Querydsl 설정 방법 (0) | 2022.08.23 |
|---|---|
| [Querydsl] 5.0.0 업데이트 변경 사항 (0) | 2021.08.05 |
| [Querydsl] 스프링 데이터가 지원하는 기능 (0) | 2021.07.27 |
| [Querydsl] Spring Data JPA와 같이 사용하기 (0) | 2021.07.26 |
| [Querydsl] SQL 함수 사용하기 (0) | 2021.07.25 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- JSON
- Linux
- QueryDSL
- 클린 아키텍처
- proto3
- Spring Boot JPA
- 스프링 데이터 jpa
- @ManyToOne
- gRPC
- spring boot jwt
- 스프링부트
- Java
- r
- 스프링 부트
- 알고리즘
- 스프링 부트 애플리케이션
- leetcode
- Spring Boot Tutorial
- Spring Data JPA
- intellij
- Spring Boot
- 스프링 부트 튜토리얼
- Jackson
- 스프링 부트 회원 가입
- spring boot app
- 함께 자라기
- 함께 자라기 후기
- 헥사고날 아키텍처
- spring boot application
- JPA
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함
