JPA JPQL vs Querydsl
목차 Post not found: jpa/querydsl/querydsl-15 Post not found: jpa/querydsl/querydsl-14 QueryDSL - 동적 쿼리와 성능 최적화 조회 QueryDSL - 순수 JPA 리포지토리와 Querydsl QueryDSL - SQL Function 호출하기 Post not found: jpa/querydsl/querydsl-10 Post not found: jpa/querydsl/querydsl-09 Post not found: jpa/querydsl/querydsl-08 QueryDSL - 조인 QueryDSL - 집계 QueryDSL - 결과 조회 QueryDSL - 검색 조건 쿼리 Post not found: jpa/querydsl/querydsl-03 JPA JPQL vs Querydsl QueryDSL 시작하기 JPQL@Testpublic void startJPQL(){ // member1 을 찾아라 Member findByJPQL = em.createQuery("select m from Member m where m.username = :username", Member.class) .setParameter("username", "member1") .getSingleResult(); assertThat(findByJPQL.getUsername()).isEqualTo("member1");} Querydsl@Testpublic void startQuerydsl(){ JPAQueryFactory queryFactory = new JPAQueryFactory(em); QMember qMember = new QMember("m"); Member findMember = queryFactory .select(qMember) .from(qMember) .where(qMember.username.eq("member1")) .fetchOne(); assertThat(findMember.getUsername()).isEqualTo("member1");} Querydsl 은 기본적으로 parameter binding 시 preparedStatement 의 parameter binding 을 사용해 SQL injection 공격으로부터 안전하다. select member0_.member_id as member_i1_1_, member0_.age as age2_1_, member0_.team_id as team_id4_1_, member0_.username as username3_1_ from member member0_ where member0_.username=? jpql 은 런타임 오류가 발생하나 querydsl 은 컴파일시 에러가 발생하게 된다.