why fetchResults() is deprecated
페이징 처리
public List<ProductSearchDto> findProductsByCondition(ProductSearchConditionDto conditionDto) {
List<ProductSearchDto> content = queryFactory
.select(Projections.constructor(
ProductSearchDto.class,
product.id,
product.productName,
product.price,
product.stockQuantity,
product.category.name
))
.from(product)
.where(buildWhere(conditionDto))
.offset(conditionDto.getPage() * conditionDto.getSize())
.limit(conditionDto.getSize())
.fetch();
long total = queryFactory
.select(product.count())
.from(product)
.where(buildWhere(conditionDto))
.fetchOne();
return content; // total은 PageImpl로 감싸 반환할 때 사용
}왜 Deprecated 됐을까?
Query의 개수
유연성
결론
Last updated