Sort 질문있습니다.
Querydsl 4RepositorySupport에 Sort를 처리해주는 로직이 없는데 이건 따로 구현해야하는건가요?
Querydsl4RepositorySupport에서
@Autowired
public void setEntityManager(EntityManager entityManager) {
Assert.notNull(entityManager, "EntityManager must not be null!");
JpaEntityInformation entityInformation = JpaEntityInformationSupport.getEntityInformation(domainClass, entityManager);
SimpleEntityPathResolver resolver = SimpleEntityPathResolver.INSTANCE;
EntityPath path = resolver.createPath(entityInformation.getJavaType());
this.entityManager = entityManager;
this.querydsl = new Querydsl(entityManager, new PathBuilder<>(path.getType(), path.getMetadata()));
this.queryFactory = new JPAQueryFactory(entityManager);
}
이 부분이 스프링 데이터에서 제공하는 Pageable안에 있는 Sort를 사용할 수 잇도록 설정한 것이라고 하셨는데 그럼
MemberTestRepository에서
public Page<Member> applyPaginationWithSort(MemberSearchCondition condition, Pageable pageable) {
return applyPagination(pageable, contentQuery -> contentQuery
.selectFrom(member)
.leftJoin(member.team, team)
.where(usernameEq(condition.getUsername()),
teamNameEq(condition.getTeamName()),
ageGoe(condition.getAgeGoe()),
ageLoe(condition.getAgeLoe())))
.orderBy(pageable.getSort());
}
와 같이 pageable.getSort()로 Sort값을 가져와 orderBy절에서 사용하면 되는건지 궁금합니다
답변 1
1
안녕하세요. 조윤호님
다음과 같이 Sort 조건을 pageable에 포함해서 던지면 해당 조건이 함께 적용됩니다. 별도로 orderBy에 적용하지 않아도 됩니다.
PageRequest pageable = PageRequest.of(0, 10, Sort.by("age"));
감사합니다.
SpringBoot 4.X에서의 Querydsl 설정
0
88
2
querydsl 오픈소스에 대한 질문
0
72
1
예제에서의 카운트 쿼리에서 join문과 where문은 필요없지 않나요?
0
109
1
Querydsl 6.X버전에 대해서 어떻게 생각하시나요?
0
317
2
여러 테이블 조인하여 통계치를 구하고자 할 때 어떤 방법이 더 효율적일까요
1
70
1
fetchResults()는 더이상 권장되지 않는다는데 맞나요?
0
160
1
querydsl sum() 메서드 없어요.
0
159
2
build 디렉터리 생성
0
136
2
자바 ORM 표준 JPA 프로그래밍 - 기본편 듣고 바로 학습해도 괜찮을까요?
0
114
2
현재 Querydsl에서 from절 서브쿼리를 지원하나요?
0
91
1
오타 제보 드립니다.
0
72
2
벌크 연산과 flush, clear
0
76
1
Run As Intellij 로 변경시 Q타입 import 불가
0
88
1
QHello import하기 문제 발생
0
147
2
등록된 함수 보는법(H2Dialect) 질문
0
68
2
5.0부터 Querydsl은 향후 fetchCount() , fetchResult() 를 지원하지 않기로 결정했다고 하는데 이에 맞는 강의
1
196
2
[환경설정 PDF 부트 3.0이후 설명 질문] build.gradle에 compileQuerydsl을 정의하지 않은 상태에서 Gradle->Tasks->other->compileQuerydsl을 클릭하라고 하는 이유가 무엇인가요??
1
200
1
querydsl 설정 문제
0
222
2
quey dsl 설정부분
0
158
2
count 쿼리 관련 질문입니다!
0
75
1
stringtemplate를 이용하여 where절 검색 방법 질문 드립니다.
0
89
1
답변부탁드리겠습니다.
0
89
2
(OrderSpecifier)관련 내용 어디있을가요
0
65
1
중급문법 벌크연산에서
0
81
2





