CASE문은 조건에 따라 다른 값을 반환하는 구문이다. 1. 단순한 CASE문조건이 특정 컬럼 값에 따라 단순하게 매칭될 때는 조건과 반환값을 나열하는 식으로 쓰면 된다.List result = queryFactory .select(member.age .when(10).then("열살") .when(20).then("스무살") .otherwise("기타")) .from(member) .fetch(); ▪️ 필드.when(조건).then(반환값).otherwise(조건 외 반환값) 2. 복잡한 CASE문비..
인프런 김영한 강의 정리/실전! Querydsl
1. JPAExpressions Querydsl에서 서브쿼리를 작성할 때, com.querydsl.jpa.JPAExpressions 사용해야한다.List result = queryFactory .selectFrom(member) .where(member.age.eq( JPAExpressions .select(memberSub.age.max()) .from(memberSub) )) .fetch();서브쿼리 시작할 때 JPAExpressions를 붙이면 된다. static import해서 쓰자!import static com.querydsl.jpa.JPAExpressions.select;static import하고 나면 JPAExpre..
1. 내부 조인join(조인 대상, 별칭으로 사용할 Q타입)List result = queryFactory .selectFrom(member) .join(member.team, team) .where(team.name.eq("teamA")) .fetch();▪️ 조인 대상은 연관관계가 있는 필드로 조인해야한다. ▪️ Q타입을 별칭으로 사용해야한다.SQL에서는 별칭을 임의로 지정하는 것이 가능하지만, Querydsl에서는 Q타입클래스만 별칭으로 지정해줄 수 있다. ▪️ 별칭을 왜 Q타입으로 쓰는지, 별칭이 필수인지 궁금했지만 관련자료를 찾지 못했다.별칭을 생략해도 코드는 잘 돌아가는 걸 확인했..
🔽Querydsl의 미지원 API 목록 링크 Deprecated List (Querydsl 5.0.0 API)JavaScript is disabled on your browser. Deprecated Methods Method and Description com.querydsl.sql.codegen.NamingStrategy.appendSchema(String, String) com.querydsl.jpa.impl.AbstractJPAQuery.fetchCount() com.querydsl.jpa.impl.AbstractJPAQuery.fetchResultsquerydsl.com1. fetchResults(), fetchCount() 역할▪️ fetchResults() : 페이징 처리된 결과 리스트,..

1. JPQL vs Querydsl✅JPQL 조회, Querydsl 조회 비교package study.querydsl;import com.querydsl.jpa.impl.JPAQueryFactory;import jakarta.persistence.EntityManager;import jakarta.transaction.Transactional;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.context.SpringBootTest;import st..

강의는 스프링부트 2.x 버전이라 3.x버전으로 세팅하는 법을 정리해보려 한다.강의 자료에 3.x 버전 설명이 있지만 중간 중간 설명이 달라서 환경설정하는데 예상보다 오래걸렸다;; 1. 프로젝트 생성접속 >> https://start.spring.io/ 이렇게 선택하고 GENERATE 버튼을 누르면 zip 폴더가 다운로드 된다.원하는 폴더로 옮긴 뒤 압축을 풀어준다. 2. IntelliJ 설정프로젝트 시작 File -> Open -> querydsl -> build.gradle 프로젝트 JDK 17 이상으로 맞추기File -> Project Structure -> Project Gradle 설정File -> Settings -> Build, Execution, Deployment -> Build Too..