jpa 쿼리 파라미터 표시

박현민·2023년 1월 19일
0

show_sql : true

spring:
    jpa:
    	hibernate:
    		show_sql : true

조회 결과

Hibernate: select count(store0_.id) as col_0_0_ from store store0_
Hibernate: select store0_.id as id1_7_0_, location1_.id as id1_5_1_, store0_.create_date as create_d2_7_0_, store0_.update_date as update_d3_7_0_, store0_.address as address4_7_0_, store0_.address_detail as address_5_7_0_, store0_.close_date as close_da6_7_0_, store0_.fax as fax7_7_0_, store0_.manager_name as manager_8_7_0_, store0_.manager_phone as manager_9_7_0_, store0_.name as name10_7_0_, store0_.open_date as open_da11_7_0_, store0_.postal_code as postal_12_7_0_, store0_.telephone as telepho13_7_0_, store0_.inspection_data_last as inspect14_7_0_, store0_.inspection_date_next as inspect15_7_0_, store0_.location_id as locatio19_7_0_, store0_.status as status16_7_0_, store0_.store_code as store_c17_7_0_, store0_.type as type18_7_0_, location1_.area_code as area_cod2_5_1_, location1_.head_office_code as head_off3_5_1_ from store store0_ inner join location location1_ on store0_.location_id=location1_.id order by store0_.store_code limit ?

파라미터도 제대로 출력 안되고 정렬도 안되어있어서 보기 불편하다.


format_sql 추가

spring:
    jpa:
    	hibernate:
        	show_sql: true
        	format_sql: true

출력결과

Hibernate: 
    select
        count(store0_.id) as col_0_0_ 
    from
        store store0_
Hibernate: 
    select
        store0_.id as id1_7_0_,
        location1_.id as id1_5_1_,
        store0_.create_date as create_d2_7_0_,
        store0_.update_date as update_d3_7_0_,
        store0_.address as address4_7_0_,
        store0_.address_detail as address_5_7_0_,
        store0_.close_date as close_da6_7_0_,
        store0_.fax as fax7_7_0_,
        store0_.manager_name as manager_8_7_0_,
        store0_.manager_phone as manager_9_7_0_,
        store0_.name as name10_7_0_,
        store0_.open_date as open_da11_7_0_,
        store0_.postal_code as postal_12_7_0_,
        store0_.telephone as telepho13_7_0_,
        store0_.inspection_data_last as inspect14_7_0_,
        store0_.inspection_date_next as inspect15_7_0_,
        store0_.location_id as locatio19_7_0_,
        store0_.status as status16_7_0_,
        store0_.store_code as store_c17_7_0_,
        store0_.type as type18_7_0_,
        location1_.area_code as area_cod2_5_1_,
        location1_.head_office_code as head_off3_5_1_ 
    from
        store store0_ 
    inner join
        location location1_ 
            on store0_.location_id=location1_.id 
    order by
        store0_.store_code limit ?

정렬이 되어서 봐줄만 하다

그리고 바인딩된 값을 확인하려면

logging.level:
  org.hibernate.SQL: debug
  org.hibernate.type: trace

이거를 추가해주면 되는데 지금 하고 있는 프로젝트에는 추가해줘도 안나온다.
다른 프로젝트 할때는 잘 나왔는데 이것만 안나오는거보면 이 프로젝트의 설정에 뭔가 문제가 있나보다.

0개의 댓글