광고
광고
반응형
SpringBoot JPA를 사용할 때, SQL 쿼리문을 표출하는 설정 관련해서 정리해보자.
요약
application.yml
spring:
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
use_sql_comments: true
logging:
level:
org:
hibernate:
type:
descriptor:
sql: trace
application.properties
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
logging.level.org.hibernate.type.descriptor.sql=trace
상세
SQL 로그 설정
Hibernate이 DB에 날리는 모든 쿼리(DDL, DML) 표출
application.yml
spring:
jpa:
properties:
hibernate:
show_sql: true
application.properties
spring.jpa.properties.hibernate.show_sql=true
SQL 포맷 설정
쿼리 들여쓰기 등의 포맷에 맞춰 표출
application.yml
spring:
jpa:
properties:
hibernate:
format_sql: true
application.properties
spring.jpa.properties.hibernate.format_sql=true
주석 표시하기
application.yml
spring:
jpa:
properties:
hibernate:
use_sql_comments: true
application.properties
spring.jpa.properties.hibernate.use_Sql_comments=true
파라미터 값 표출
이 옵션을 사용하지 않으면 기본적으로 파라미터 값이 무엇인지는 알 수 없고, 바인딩 쿼리로그만 찍힌다.
application.yml
logging:
level:
org:
hibernate:
type:
descriptor:
sql: trace
application.properties
logging.level.org.hibernate.type.descriptor.sql=trace
728x90
반응형
'JVM > JPA' 카테고리의 다른 글
[JPA] N+1 발생 원인과 해결책 (3) | 2023.05.30 |
---|---|
[JPA] QueryDSL 소개 및 프로젝트 설정하기 (0) | 2023.05.25 |
[JPA] 기본 키 전략과 Entity Custom ID Generator 구현하기 (0) | 2022.08.05 |
[JPA] JpaRepository를 상속 받은 인터페이스는 @Repository 없이 어떻게 인스턴스화될까? (0) | 2022.07.26 |
댓글