[Exception ์ •๋ฆฌ] com.querydsl.core.types.ExpressionException: No constructor found for class

2022. 2. 5. 17:26ใ†๊ฐœ๋… ์ •๋ฆฌ ์ž‘์—…์‹ค/๋ฌธ์ œ ์ •๋ฆฌ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿš€ Code Content

 

Query dsl์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฃผ๋‹ˆํ•˜๋ž‘์ด ๋งŒ๋“ค ๊ฐ€์กฑ ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ฒŒ์‹œํŒ์— ๋ชฉ๋ก ์กฐํšŒ๋ฅผ ๊ตฌํ˜„ํ•˜๋ ค๊ณ  ํ•˜๋Š” ๊ฒƒ์ด์—์š”.

 

 

 

์Šคํ”„๋ง๊ณผ JPA๋ฅผ ํ™œ์šฉํ•œ ์ž๋ฐ” ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ ์„ธํŠธ

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

 

     ๐Ÿ”ฝ  SystemManualQueryRepository

package com.hongga.repository.querydsl.system_manual;

import com.hongga.dto.SystemManualResponseDTO;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import java.util.List;

import static com.hongga.entity.system_manual.QSystemManual.systemManual;

/**
 * ์‹œ์Šคํ…œ ๋ฉ”๋‰ด์–ผ DB Query ์ž‘์—…์„ ์œ„ํ•œ Querydsl Repository
 * <pre>
 * <b>History:</b>
 *    ์ฃผ๋‹ˆํ•˜๋ž‘, 1.0, 2022.02.05 ์ตœ์ดˆ ์ž‘์„ฑ
 * </pre>
 *
 * @author ์ฃผ๋‹ˆํ•˜๋ž‘
 * @version 1.0, 2022.02.05 ์ตœ์ดˆ ์ž‘์„ฑ
 * @See "Not thing"
 * @see <a href=""></a>
 */

@RequiredArgsConstructor @Slf4j
@Repository public class SystemManualQueryRepository {

    private final JPAQueryFactory jpaQueryFactory;
    private final EntityManager entityManager;

    // ์ „์ฒด(๋ชฉ๋ก) ์กฐํšŒ
    public Page<SystemManualResponseDTO> systemManualFindAll(Pageable pageable) {   // ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ

        log.info("SystemManualQueryRepository๊ฐ€ ๋™์ž‘ํ•˜์˜€์Šต๋‹ˆ๋‹ค!");
        log.info("systemManualFindAll(Pageable pageable, Long memberId)์ด ๋™์ž‘ํ•˜์˜€์Šต๋‹ˆ๋‹ค!");

        List<SystemManualResponseDTO> systemManualDTOList = jpaQueryFactory
                .select(Projections.constructor(SystemManualResponseDTO.class,
                        systemManual.systemManualId.as("systemManualId"),
                        systemManual.writer.nickName.as("memberNickname"),
                        systemManual.title.as("title"),
                        systemManual.registerDate.as("registerDate"),
                        systemManual.modifyDate.as("modifyDate")))

                .from(systemManual)
                .innerJoin(systemManual.writer)
                .orderBy(systemManual.systemManualId.desc())
                .fetch();

        log.info("List<SystemManualResponseDTO> systemManualDTOList = jpaQueryFactory.select๊ฐ€ ๋™์ž‘ ์™„๋ฃŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!");
        log.info("ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค!");

        int start = (int)pageable.getOffset();
        int end = Math.min((start + pageable.getPageSize()), systemManualDTOList.size());

        log.info("ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ๊ฐ€ ์™„๋ฃŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!");

        return new PageImpl<>(systemManualDTOList.subList(start, end), pageable, systemManualDTOList.size());

    } // systemManualFindAll(Pageable pageable) ๋
} // class ๋

 

 

     ๐Ÿ”ฝ  SystemManualResponseDTO

package com.hongga.dto;

import lombok.*;

import java.time.LocalDateTime;

/**
 * System Manual ์‘๋‹ต์„ ์œ„ํ•œ DTO
 * <pre>
 * <b>History:</b>
 *    ์ฃผ๋‹ˆํ•˜๋ž‘, 1.0, 2022.02.05 ์ตœ์ดˆ ์ž‘์„ฑ
 * </pre>
 *
 * @author ์ฃผ๋‹ˆํ•˜๋ž‘
 * @version 1.0, 2022.02.05 ์ตœ์ดˆ ์ž‘์„ฑ
 * @See "์ฝ”๋“œ๋กœ ๋ฐฐ์šฐ๋Š” ์Šคํ”„๋ง ๋ถ€ํŠธ ์›น ํ”„๋กœ์ ํŠธ"
 * @see <a href=""></a>
 */

@Getter @NoArgsConstructor @AllArgsConstructor @Builder
public class SystemManualResponseDTO {

    private Long systemManualId;                        // ๊ฒŒ์‹œ๊ธ€ ๋ฒˆํ˜ธ

    private String memberNickname;                      // ์ž‘์„ฑ์ž ๋‹‰๋„ค์ž„

    private String title;                               // ๊ธ€ ์ œ๋ชฉ

    private LocalDateTime registerDate, modifyDate;     // ๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก / ์ˆ˜์ •์ผ

    private Long writerId;								// ์ž‘์„ฑ์ž ๊ณ ์œ ๋ฒˆํ˜ธ

} // class ๋

 

 

โš ๏ธ ๋ฌธ์ œ ๋ฐœ์ƒ!

 

2022-02-05 17:06:15.829 ERROR 7519 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.querydsl.core.types.ExpressionException: No constructor found for class com.hongga.dto.SystemManualResponseDTO with parameters: [class java.lang.Long, class java.lang.String, class java.lang.String, class java.time.LocalDateTime, class java.time.LocalDateTime]] with root cause

com.querydsl.core.types.ExpressionException: No constructor found for class com.hongga.dto.SystemManualResponseDTO with parameters: [class java.lang.Long, class java.lang.String, class java.lang.String, class java.time.LocalDateTime, class java.time.LocalDateTime]
	at com.querydsl.core.util.ConstructorUtils.getConstructorParameters(ConstructorUtils.java:121) ~[querydsl-core-5.0.0.jar:na]
	at com.querydsl.core.types.ConstructorExpression.<init>(ConstructorExpression.java:84) ~[querydsl-core-5.0.0.jar:na]
	at com.querydsl.core.types.ConstructorExpression.<init>(ConstructorExpression.java:74) ~[querydsl-core-5.0.0.jar:na]
	at com.querydsl.core.types.Projections.constructor(Projections.java:121) ~[querydsl-core-5.0.0.jar:na]
	at com.hongga.repository.querydsl.system_manual.SystemManualQueryRepository.systemManualFindAll(SystemManualQueryRepository.java:44) ~[classes/:na]
	at com.hongga.repository.querydsl.system_manual.SystemManualQueryRepository$$FastClassBySpringCGLIB$$9e2c3609.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783) ~[spring-aop-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.15.jar:5.3.15]
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.15.jar:5.3.15]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-5.3.15.jar:5.3.15]
	at com.hongga.repository.querydsl.system_manual.SystemManualQueryRepository$$EnhancerBySpringCGLIB$$5cf2a422.systemManualFindAll(<generated>) ~[classes/:na]
	at com.hongga.service.SystemManualServiceImpl.systemManualList(SystemManualServiceImpl.java:119) ~[classes/:na]
	at com.hongga.controller.system_manual.SystemManualController.systemManualList(SystemManualController.java:87) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.56.jar:4.0.FR]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.15.jar:5.3.15]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.56.jar:4.0.FR]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter.doFilterInternal(DefaultLogoutPageGeneratingFilter.java:58) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:237) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:223) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:219) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:213) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.6.1.jar:5.6.1]
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.15.jar:5.3.15]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.15.jar:5.3.15]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
	at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]

 

 

๐Ÿค” ๋ฌด์—‡์„ ํ•˜๋ ค๊ณ  ํ•˜์˜€๋Š”๊ฐ€?

์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด Postman์„ ์ด์šฉํ•˜์—ฌ ์ฃผ๋‹ˆํ•˜๋ž‘์ด ๋งŒ๋“  ๊ฒŒ์‹œํŒ์˜ ๋ชฉ๋ก์„ ๋ชจ๋‘ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” API๋ฅผ ํ˜ธ์ถœํ•œ ๊ฒƒ์ด์—์š”.

๊ทธ๋Ÿฐ๋ฐ, 500 Error๊ฐ€ ๋ฐ˜ํ™˜์ด ๋˜์—ˆ๊ณ , ์œ„์™€ ๊ฐ™์ด ์ƒ์„ฑ์ž ๊ด€๋ จ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒƒ์ด์—์š”.

 

๐Ÿค” ์›์ธ ๋ถ„์„

 

 

๋ฐ˜์‘ํ˜•

์œ„์˜ ๋ฌธ์ œ๋Š” ๋ฐ”๋กœ Query dsl์˜ Respository์™€ DTO์˜ ํ•„๋“œ๊ฐ€ ์ •ํ™•ํ•˜๊ฒŒ ์ผ์น˜ํ•ด์•ผ ํ•˜๋Š”๋ฐ ์ผ์น˜ํ•˜์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ธ ๊ฒƒ์ด์—์š”.

DTO ํ•„๋“œ์—๋Š” writerId๋ผ๋Š” ํ•„๋“œ๊ฐ€ ์žˆ์ง€๋งŒ ์ด๊ฒƒ์„ Repository์—์„œ๋Š” ์ฒ˜๋ฆฌ๋ฅผ ํ•ด ์ฃผ์ง€ ์•Š์€ ๊ฒƒ์ด ๋ฌธ์ œ๊ฐ€ ๋œ ๊ฒƒ์ด์—์š”.

 

 

๐Ÿป ๋ฌธ์ œ ํ•ด๊ฒฐ!

 

 

DTO์— writerId๋ผ๋Š” ํ•„๋“œ๋ฅผ ์—†์• ๊ณ , ๋‹ค์‹œ API๋ฅผ ํ˜ธ์ถœํ•ด ๋ณด๋ฉด ๋ฌธ์ œ๋Š” ํ•ด๊ฒฐ ๋˜๋Š” ๊ฒƒ์ด์—์š”.

 

 

 

 

๐Ÿ’ก ์ฐธ๊ณ  ์ž๋ฃŒ

DTO์—์„œ ์ •์˜ํ•˜๋Š” ํ•„๋“œ์™€ Repository์—์„œ select๋กœ ํ‘œํ˜„ํ•˜๊ณ ์ž ํ•˜๋Š” ํ•„๋“œ๊ฐ€ ์™„์ „ํžˆ ์ผ์น˜ํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ์ด Query dsl์„ ์‚ฌ์šฉํ•  ๋•Œ ๊ด€๊ฑด์ด๋‹ค.

1. ๋ชจ๋“  ํ•„๋“œ์˜ ํƒ€์ž…์ด ์ผ์น˜ํ•ด์•ผ ํ•œ๋‹ค.
2. ๋ชจ๋“  ํ•„๋“œ์˜ ์ˆœ์„œ๊ฐ€ ์ผ์น˜ํ•ด์•ผ ํ•œ๋‹ค.
3. Repository(Query dsl์šฉ) ์ชฝ์—์„œ์˜ ํ•„๋“œ๋ช…๊ณผ DTO ์ชฝ์—์„œ์˜ ํ•„๋“œ๋ช…์ด ์ •ํ™•ํžˆ ์ผ์น˜ํ•ด์•ผ ํ•œ๋‹ค. ๋งŒ์•ฝ ๋‹ค๋ฅด๋‹ค๋ฉด ์œ„์˜ 'SystemManualQueryRepository.class' ์ฒ˜๋Ÿผ .as(๋ณ„์นญ) Method๋ฅผ ํ†ตํ•ด DTO ์ชฝ์—์„œ์˜ ํ•„๋“œ๋ช…๊ณผ ๊ฐ™๋„๋ก ๋ณ„์นญ์„ ์ง€์ •ํ•ด ์ค€๋‹ค. 

 

 

 

์Šคํ”„๋ง๊ณผ JPA๋ฅผ ํ™œ์šฉํ•œ ์ž๋ฐ” ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ ์„ธํŠธ

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

728x90
๋ฐ˜์‘ํ˜•