veluxer62 / veluxer62.github.io

veluxer's blog
http://veluxer62.github.io
MIT License
1 stars 0 forks source link

8월 개발 이슈 #677

Closed veluxer62 closed 9 months ago

veluxer62 commented 11 months ago

Motivation

제품의 방향을 다시한번 전환하는 프로젝트를 진행중이다. 작년도 그렇고 올해도 제품의 성격을 크게 바꾸는 프로젝트를 진행해왔는데 이번에는 와우포인트를 잘 찾아서 제품이 잘 성장하면 좋겠다.

Suggestion

1

veluxer62 commented 11 months ago

소나큐브 3.x.x 버전이 gradle 8로 업그레이드 하면 실행이 안되서 4.x.x로 업그레이드 해야한다.

https://community.sonarsource.com/t/sonarqube-plugin-for-gradle-8/83936

veluxer62 commented 11 months ago

qeury dsl에서 null 값이 마지막에 오고 값이 있는 경우에는 정렬을 하고싶지 않으면 case문을 써서 별도로 처리해야함.

private fun promotionPriceOrder(): OrderSpecifier<Int> {
        val cases = CaseBuilder()
            .`when`(orderableVendorCatalogProduct.promotionPrice.isNull).then(2)
            .otherwise(1)
        return OrderSpecifier(Order.ASC, cases)
    }

그렇지 않고 null last 와 같은 구문을 쓰면 값이 있는 경우에 정렬을 해서 원하지 않는 정렬이 될 수 있음

.orderBy(
                orderableVendorCatalogProduct.promotionPrice.asc().nullsLast(),
            )
veluxer62 commented 10 months ago

DB의 삭제는 row가 제거되는거다. 그럼 어플리케이션에서의 삭제 개념은??

veluxer62 commented 10 months ago

FK 오류가 발생하였을 때 500으로 처리하지 않고 사용자에게 공통된 메시지로 안내하는 방법이 없을까

veluxer62 commented 10 months ago

sync 설정할때 비동기 잡이 시스템 종료될때 graceful하게 종료되도록 설정하는 방법

@Bean
public TaskExecutor taskExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
    taskExecutor.initialize();
    return taskExecutor;
}

추가로

만약 queue 사이즈가 모자라면 자동으로 thread를 생성하도록 실패전략을 가져가는 설정

override fun getAsyncExecutor(): Executor {
        return ThreadPoolTaskExecutor().apply {
            setWaitForTasksToCompleteOnShutdown(true)
            initialize()
        }
    }
veluxer62 commented 10 months ago

TestConfiguration은 경로와 파일명이 동일하면 별도로 import를 해주지 않아도 된다.

veluxer62 commented 10 months ago

bucket4j를 통해 스로틀링을 걸어두니 테스트가 많은 경우 스로틀링으로 인해 테스트 검증이 원치 않게 실패함 그래서 테스트 환경에서 스로틀링을 제거함

veluxer62 commented 10 months ago

mock 서버를 이용하여 테스트할때 응답을 mocking 하는 경우 구현된 코드에 따라 테스트하기 까다로운 경우가 있다. 예를들어 응답하는 값에 따라 분기를 해야한다던가, 응답 ID를 활용한다던가 하는 경우 말이다.

이럴때 아래와 같이 랜덤한 값을 반환하게 만들어버리면 테스트가 실패하는 경우가 있는데

fun Mockery.getSendbirdOrderGroupChannel() {
    sendbirdApi.whenWithDefault(
        requestDefinition = HttpRequest.request()
            .withMethod(HttpMethod.GET.name())
            .withPath("/v3/group_channels/.+"),
    ).respond(
        HttpResponse.response()
            .withStatusCode(200)
            .withBody(
                json(
                    """
                    {
                      "channel_url": "${generateId()}",
                      "name": "${generateString()}",
                      "data": ""
                    }
                    """.trimIndent(),
                ),
            ),
    )
}

이런경우 여러가지 선택을 할 수 있다.

첫번째는 함수의 매개변수로 넘기는 방법이다.

fun Mockery.getSendbirdOrderGroupChannel(
    channelUrl: String,
    name: String,
) {
    sendbirdApi.whenWithDefault(
        requestDefinition = HttpRequest.request()
            .withMethod(HttpMethod.GET.name())
            .withPath("/v3/group_channels/.+"),
    ).respond(
        HttpResponse.response()
            .withStatusCode(200)
            .withBody(
                json(
                    """
                    {
                      "channel_url": "${channelUrl}",
                      "name": "${name}",
                      "data": ""
                    }
                    """.trimIndent(),
                ),
            ),
    )
}

이게 가장 직관적이지만 상황에 따라서는 매개변수를 넘기지 못하는 경우가 있다. 시스템 내부에서 값을 생성한다던지 하는 등...

두번째는 요청한 매개변수를 그대로 반환하도록 하는 방법이 있다.

mock server에서는 response template 이라는 기능을 제공해주는데, 요청한 값을 참조하여 반환값을 지정할 수 있는 기능을 제공해준다.

https://www.mock-server.com/mock_server/response_templates.html#mustache_templates

해당 기능을 아래와 같이 활용해볼 수 있다. 이렇게 하면 요청한 userId를 응답값에 그대로 반환할 수 있다.

fun Mockery.getSendbirdUser() {
    sendbirdApi.whenWithDefault(
        HttpRequest.request()
            .withMethod(HttpMethod.GET.name())
            .withPath("/v3/users/{userId}")
            .withPathParameters(
                param("userId", ".+"),
            ),
    ).respond(
        template(
            HttpTemplate.TemplateType.MUSTACHE,
            """
            {
                "statusCode": 200,
                "body": {
                  "user_id": "{{ request.pathParameters.userId.0 }}",
                  "nickname": "${generateId()}"
                }
            }
            """.trimIndent(),
        ),
    )
}
veluxer62 commented 10 months ago

query dsl에서 fetch join 사용 시 on절을 명시적으로 사용하면 fetch join이 제대로 동작안함.

이걸

val query = from(orderableVendorCatalogProduct)
            .join(orderableVendorProduct)
            .on(orderableVendorCatalogProduct.id.eq(orderableVendorProduct.orderableVendorCatalogProduct.id))
            .fetchJoin()
            .where(filter.getExpression())
            .orderBy(
                promotionPriceOrder(),
                orderableVendorCatalogProduct.createdAt.desc(),
            )

이렇게 바꿔줘야함

val query = from(orderableVendorCatalogProduct)
            .join(orderableVendorCatalogProduct.orderableVendorProduct, orderableVendorProduct)
            .fetchJoin()
            .where(filter.getExpression())
            .orderBy(
                promotionPriceOrder(),
                orderableVendorCatalogProduct.createdAt.desc(),
            )

query 결과

적용전

select count(o1_0.id) from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=?
select count(o1_0.id) from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id='018a2752-9505-24a4-8f27-68c5096b9da0';
Hibernate: select o1_0.id,o1_0.created_at,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=? order by case when (o1_0.promotion_price is null) then ? else 1 end asc,o1_0.created_at desc offset ? rows fetch first ? rows only
2023-08-24T20:33:59.014+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839014 | took 3ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=? order by case when (o1_0.promotion_price is null) then ? else 1 end asc,o1_0.created_at desc offset ? rows fetch first ? rows only
select o1_0.id,o1_0.created_at,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id='018a2752-9505-24a4-8f27-68c5096b9da0' order by case when (o1_0.promotion_price is null) then 2 else 1 end asc,o1_0.created_at desc offset 0 rows fetch first 10 rows only;
Hibernate: select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id=?
2023-08-24T20:33:59.020+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839020 | took 3ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id=?
select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id='018a2752-96b1-f170-d263-c2a588c22a20';
Hibernate: select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id=?
2023-08-24T20:33:59.023+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839023 | took 3ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id=?
select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id='018a2752-9505-24a4-8f27-68c5096b9da0';
Hibernate: select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id=?
2023-08-24T20:33:59.027+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839027 | took 2ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id=?
select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id='018a2752-9505-24a4-8f27-68c5096b9da2';
Hibernate: select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id=?
2023-08-24T20:33:59.031+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839031 | took 2ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id=?
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id='018a2752-96b1-f170-d263-c2a588c22a20';
Hibernate: select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id=?
2023-08-24T20:33:59.034+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839034 | took 2ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id=?
select o1_0.id,o1_0.created_at,o1_0.erp_code,o1_0.is_market_price,o1_0.name,o1_0.orderable_vendor_id,o1_0.orderable_vendor_catalog_product_id,o1_0.standard,o1_0.unit,o1_0.unit_price,o1_0.updated_at,o1_0.vat_included from orderable_vendor_product o1_0 where o1_0.orderable_vendor_catalog_product_id='018a2752-9706-7d18-cb9e-5de7203ea54d';
Hibernate: select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id=?
2023-08-24T20:33:59.037+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839037 | took 2ms | statement | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id=?
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 left join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o1_0.id='018a2752-9706-7d18-cb9e-5de7203ea54d';
2023-08-24T20:33:59.042+09:00  INFO 89912 --- [  XNIO-1 task-2] p6spy                                    : #1692876839042 | took 2ms | commit | connection 11| url jdbc:postgresql://localhost:51023/test_database?loggerLevel=OFF

;
2023-08-24T20:33:59.087+09:00  INFO 89912 --- [pool-1-thread-1] com.spoqa.cart.Constants 

적용후

select count(o1_0.id) from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=?
select count(o1_0.id) from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id='018a2751-27f9-d26d-1488-10c0ccf031a8';
Hibernate: select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=? order by case when (o1_0.promotion_price is null) then ? else 1 end asc,o1_0.created_at desc offset ? rows fetch first ? rows only
2023-08-24T20:32:25.527+09:00  INFO 89881 --- [  XNIO-1 task-2] p6spy                                    : #1692876745527 | took 5ms | statement | connection 11| url jdbc:postgresql://localhost:50933/test_database?loggerLevel=OFF
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id=? order by case when (o1_0.promotion_price is null) then ? else 1 end asc,o1_0.created_at desc offset ? rows fetch first ? rows only
select o1_0.id,o1_0.created_at,o2_0.id,o2_0.created_at,o2_0.erp_code,o2_0.is_market_price,o2_0.name,o2_0.orderable_vendor_id,o2_0.standard,o2_0.unit,o2_0.unit_price,o2_0.updated_at,o2_0.vat_included,o1_0.promotion_price from orderable_vendor_catalog_product o1_0 join orderable_vendor_product o2_0 on o1_0.id=o2_0.orderable_vendor_catalog_product_id where o2_0.orderable_vendor_id='018a2751-27f9-d26d-1488-10c0ccf031a8' order by case when (o1_0.promotion_price is null) then 2 else 1 end asc,o1_0.created_at desc offset 0 rows fetch first 10 rows only;
Hibernate: select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id=?
2023-08-24T20:32:25.532+09:00  INFO 89881 --- [  XNIO-1 task-2] p6spy                                    : #1692876745532 | took 4ms | statement | connection 11| url jdbc:postgresql://localhost:50933/test_database?loggerLevel=OFF
select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id=?
select o1_0.id,o1_0.authentication_attachments,o1_0.business_address_id,o1_0.business_name,o1_0.created_at,o1_0.can_deliver_friday,o1_0.can_deliver_monday,o1_0.can_deliver_saturday,o1_0.can_deliver_sunday,o1_0.can_deliver_thursday,o1_0.can_deliver_tuesday,o1_0.can_deliver_wednesday,o1_0.email,o1_0.can_inquiry_friday,o1_0.can_inquiry_monday,o1_0.can_inquiry_saturday,o1_0.can_inquiry_sunday,o1_0.can_inquiry_thursday,o1_0.can_inquiry_tuesday,o1_0.can_inquiry_wednesday,o1_0.inquiryable_time,o1_0.invitation_code,o1_0.meta_orderable_vendor_id,o1_0.name,o1_0.reg_num,o1_0.representative,o1_0.updated_at from orderable_vendor o1_0 where o1_0.id='018a2751-27f9-d26d-1488-10c0ccf031a8';
Hibernate: select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id=?
2023-08-24T20:32:25.536+09:00  INFO 89881 --- [  XNIO-1 task-2] p6spy                                    : #1692876745536 | took 2ms | statement | connection 11| url jdbc:postgresql://localhost:50933/test_database?loggerLevel=OFF
select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id=?
select m1_0.id,m1_0.advertisement_enabled,m1_0.certification_comment,m1_0.detail_images,m1_0.introduction,m1_0.introduction_summary,m1_0.major_products,m1_0.representative_image,m1_0.available_payment_methods,m1_0.business_conditions,m1_0.business_types,m1_0.chat_inquirable,m1_0.delivery_methods,m1_0.delivery_regions,m1_0.delivery_time_range,m1_0.establishment_date,m1_0.main_products,m1_0.major_product_categories,m1_0.major_trade_store_categories,m1_0.matching_enabled,m1_0.memo,m1_0.minimum_order,m1_0.new_store_extendable,m1_0.next_day_delivery_deadline,m1_0.officials,m1_0.payment_intervals,m1_0.preferred_delivery_regions,m1_0.storage_address_id from meta_orderable_vendor m1_0 where m1_0.id='018a2751-27fa-cb6b-82ba-16f0e847382a';
2023-08-24T20:32:25.541+09:00  INFO 89881 --- [  XNIO-1 task-2] p6spy                                    : #1692876745541 | took 2ms | commit | connection 11| url jdbc:postgresql://localhost:50933/test_database?loggerLevel=OFF

;
2023-08-24T20:32:25.580+09:00  INFO 89881 --- [pool-1-thread-1] com.spoqa.cart.Constants   
veluxer62 commented 10 months ago

One-To-One을 사용하면 Lazy를 선언해도 Eager 로딩을 사용하는걸 볼 수 있다. MapsId 를 사용하면 해결할 수 있을 듯 한데 테스트 해봐야할듯

https://thorben-janssen.com/hibernate-tip-lazy-loading-one-to-one/

veluxer62 commented 10 months ago

JPA 사용할때 주의할 사례

https://github.com/spoqa/dodo-cart-service-kotlin/pull/3705