-
[Querydsl] BooleanBuilder과 BooleanExpressionSpring 2022. 8. 26. 05:17
BooleanBuilder
쿼리를 조건별로 쌓아서 동적 쿼리로 쓸 수 있음
where문에 들어가는 조건들을 넣어주는 컨테이너
and나 or 사용 가능
BooleanExpression
메서드가 늘어나지만 메서드 명을 통해 어떤 기능인지 확인이 가능다는 것 등 가독성이 증가하며, 메서드를 이용하므로 재사용성이 증가
Predicate의 구현체
null일 때 무시될 수 있고, and 또는 or절을 통해 조합 가능
BooleanExpression ⇨ qGuestbook.title.contains(keyword) 같이 표현식의 결과로 반환되는 값
BooleanBuilder ⇨ 이러한 표현식을 모아서 사용할 수 있도록 도와주는 도구
=> BoolenaBuilder는 and() 혹은 or()의 파라미터로 BooleanBuilder를 전달 가능하기 때문에 복합적인 쿼리 생성 가능
'Spring' 카테고리의 다른 글
[Spring Security] kakao 소셜 로그인 (0) 2023.11.21 Event Publisher / Event Listener (0) 2023.07.04 [Test Code] @NotBlank 테스트 코드 작성 방법 (0) 2023.07.03 SecurityConfig - SecurityFilterChain (0) 2022.11.13 Spring 개념 (0) 2022.08.08