QueryDSL - Q-Type 활용

목차

Q 클래스 인스턴스를 사용하는 2가지 방법

  • 생성자기 parameter 를 넘기게 되면 해당 값으로 alias 가 걸리게 된다.
// 별칭 직접 지정 
QMember qMember = new QMember("m");
// 기본 인스턴스 사용
QMember qMember = QMember.member;

use_sql_comments 옵션을 true 로 설정하게 되면 jpql comment 를 볼 수 있다.

Config

spring:
datasource:
# url: jdbc:h2:~/querydsl
url: jdbc:h2:tcp://localhost/~/querydsl
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create-drop
properties:
hibernate:
# show_sql: true
format_sql: true
use_sql_comments: true
logging.level:
org.hibernate.SQL: debug
# org.hibernate.type: trace
/* select
m
from
Member m
where
m.username = :username */ 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=?
Share