You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1️⃣ Querydsl 소개 1 - 기존 방식의 문제점
갑자기 퇴근 10분 전, 긴급 요구사항이 추가가 된다면 어떨까

나이, 이름 등등 검색 조건을 추가한다고 한다면 ..?
단순하다고 생각하여 위와 같이 쿼리를 추가할 수 있다.
그러나 위의 쿼리에는 문제점이 존재한다.
띄어쓰기를 안해줬기 때문에 원하는 쿼리문이 제대로 실행이 되지 않는 문제가 발생한다.
Query 의 문제점
에러는 크게 컴파일 에러와, 런타임 에러로 나뉘는데
컴파일에러는 바로 잡을 수 있기 때문에 좋은 에러, 런타임 에러는 어디서 발생했는 지 파악하기 어렵기 때문에 나쁜 에러로 나뉠 수 있다.
만약 SQL 이 클래스처럼 타입이 있고, 자바 코드로도 작성할 수 있다면 type-safe 하게 될 것이다.
type-safe 란 컴파일 시 에러를 체크할 수 있다.
QueryDSL
JPA 에서 QUERY 방법은 크게 3가지
1. JPQL (HQL)
2. Criteria API
3. MetaModel Criteria API
2️⃣ Querydsl 소개2 - 해결
QueryDSL 분석
DSL
QueryDSL
Type-safe Query Type 생성
Querydsl-JPA
아까와 같은 20~40살, 성은 김씨이며, 나이 많은 순서로 3명을 출력하는 동일한 구문으로 비교해보자.
아래와 같은 회원 Query 가 자동으로 생성된다.

아래와 같은 쿼리가 생성된다.
아래와 같은 방식으로 작동한다.

Querydsl-JPA
Querydsl-JPA 의 기능 살펴보기
SpringDataJPA + Querydsl
QueryDSL 결론
All reactions