172만명의 커뮤니티!! 함께 토론해봐요.
미해결
자바 ORM 표준 JPA 프로그래밍 - 기본편
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 안녕하세요, 영한님! 영한님 수업을 새겨듣고 있는 수강자입니다! 다름이 아니라, JPA 소개파트의 "1차 캐시와 동일성 보장(15분 30초경)" 에서 말씀하신 동일성이 "각 Entity가 참조하는 메모리 주소가 같지 않아도 값을 통해 같음을 보장"한다는 뜻과 일맥상통한 내용인가요? Java의 equals에 대해서 공부하다가 동일성이란 단어가 동일한 의미로 쓰이는지 궁금해서 여쭈어봐요! 만약에 같은 뜻이라면, "같은 엔티티를 반환한다"는 말을 "참조하는 메모리 주소가 같지는 않고, 값만 같은 엔티티를 반환한다"로 이해해도 될까요?? 질문 들어주셔서 감사합니다. 오늘도 좋은 하루 보내세요!!
윤수정
2023-06-28T08:35:59.913Z
댓글 1
좋아요 0
조회수 660
해결됨
나도코딩의 자바 기본편 - 풀코스 (20시간)
안녕하세요! 7강 마무리 퀴즈를 스스로 풀어보며 의문점이 생겨 질문 남깁니다. 저는 이런식으로 name 변수를 선언하고 cook() 메소드에 this.name을 활용했는데, 강의에선 기본 생성자와 name을 매개변수로 하는 생성자를 정의하고 풀어 주셨더라구요! 결과는 같게 나오지만 혹시 생성자를 사용하는게 더 좋은 코딩 방법인지, 제가 한 방식이 결과는 맞지만 논리적 오류가 있는지 궁금합니다. 그리고 강의 잘 듣고 있습니다. 감사합니다!
andy15948
2023-06-27T07:21:12.450Z
댓글 1
좋아요 0
조회수 176
미해결
Practical Testing: 실용적인 테스트 가이드
안녕하세요. 강의 잘 듣고 있습니다. 만약에 Service를 Write / Read 로 나눠서 관리를 한다고 하면 Service 패키지쪽의 DTO도 나눠서 생성을 하시나요? 아니면 그 부분은 같이 사용하시는 편인가요?
spring tdd jpa mockito 소프트웨어-테스트 junit5
조재연
2023-06-27T02:52:18.203Z
댓글 1
좋아요 0
조회수 531
미해결
실전! Querydsl
<code> 17:02:50.381 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate] 17:02:50.391 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support .DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)] 17:02:50.427 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [study.querydsl.QuerydslBasicTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper] 17:02:50.439 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [study.querydsl.QuerydslBasicTest], using SpringBootContextLoader 17:02:50.443 [main] DEBUG org.springframework.test.context.support .AbstractContextLoader - Did not detect default resource location for test class [study.querydsl.QuerydslBasicTest]: class path resource [study/querydsl/QuerydslBasicTest-context.xml] does not exist 17:02:50.444 [main] DEBUG org.springframework.test.context.support .AbstractContextLoader - Did not detect default resource location for test class [study.querydsl.QuerydslBasicTest]: class path resource [study/querydsl/QuerydslBasicTestContext.groovy] does not exist 17:02:50.444 [main] INFO org.springframework.test.context.support .AbstractContextLoader - Could not detect default resource locations for test class [study.querydsl.QuerydslBasicTest]: no resource found for suffixes {-context.xml, Context.groovy}. 17:02:50.445 [main] INFO org.springframework.test.context.support .AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [study.querydsl.QuerydslBasicTest]: QuerydslBasicTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 17:02:50.482 [main] DEBUG org.springframework.test.context.support .ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [study.querydsl.QuerydslBasicTest] 17:02:50.541 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\alita\Desktop\querydsl\querydsl\out\production\classes\study\querydsl\QuerydslApplication.class] 17:02:50.542 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration study.querydsl.QuerydslApplication for test class study.querydsl.QuerydslBasicTest 17:02:50.646 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [study.querydsl.QuerydslBasicTest]: using defaults. 17:02:50.646 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support .DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support .DependencyInjectionTestExecutionListener, org.springframework.test.context.support .DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 17:02:50.664 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@3a1dd365, org.springframework.test.context.support .DirtiesContextBeforeModesTestExecutionListener@395b56bb, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@256f8274, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@68044f4, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@52d239ba, org.springframework.test.context.support .DirtiesContextTestExecutionListener@315f43d5, org.springframework.test.context.transaction.TransactionalTestExecutionListener@68fa0ba8, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@6c5945a7, org.springframework.test.context.event.EventPublishingTestExecutionListener@2f05be7f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@640f11a1, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@5c10f1c3, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@7ac2e39b, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@78365cfa, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@64a8c844, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@3f6db3fb] 17:02:50.668 [main] DEBUG org.springframework.test.context.support .AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@424fd310 testClass = QuerydslBasicTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1a45193b testClass = QuerydslBasicTest, locations = '{}', classes = '{class study.querydsl.QuerydslApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@1e13529a, org.springframework.boot.test.autoconfigure.properties .PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@93081b6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@16c069df, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7c3fdb62, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@4d6025c5, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@80ec1f8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null]. . ____ _ /\\ / ___'_ __ ( _)_ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.12) 2023-06-26 17:02:51.012 INFO 16528 --- [ main] study.querydsl.QuerydslBasicTest : Starting QuerydslBasicTest using Java 11.0.15 on DESKTOP-UKCCBE9 with PID 16528 (started by alita in C:\Users\alita\Desktop\querydsl\querydsl) 2023-06-26 17:02:51.013 INFO 16528 --- [ main] study.querydsl.QuerydslBasicTest : No active profile set, falling back to 1 default profile: "default" 2023-06-26 17:02:51.530 INFO 16528 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2023-06-26 17:02:51.544 INFO 16528 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7 ms. Found 0 JPA repository interfaces. 2023-06-26 17:02:52.025 INFO 16528 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2023-06-26 17:02:52.079 INFO 16528 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.15.Final 2023-06-26 17:02:52.234 INFO 16528 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations { 5.1.2.Final } 2023-06-26 17:02:52.480 INFO 16528 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2023-06-26 17:02:52.647 INFO 16528 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2023-06-26 17:02:52.678 INFO 16528 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect 2023-06-26 17:02:53.242 DEBUG 16528 --- [ main] org.hibernate.SQL : alter table member drop foreign key FKcjte2jn9pvo9ud2hyfgwcja0k Hibernate: alter table member drop foreign key FKcjte2jn9pvo9ud2hyfgwcja0k 2023-06-26 17:02:53.256 DEBUG 16528 --- [ main] org.hibernate.SQL : drop table if exists hello Hibernate: drop table if exists hello 2023-06-26 17:02:53.260 DEBUG 16528 --- [ main] org.hibernate.SQL : drop table if exists hibernate_sequence Hibernate: drop table if exists hibernate_sequence 2023-06-26 17:02:53.266 DEBUG 16528 --- [ main] org.hibernate.SQL : drop table if exists member Hibernate: drop table if exists member 2023-06-26 17:02:53.270 DEBUG 16528 --- [ main] org.hibernate.SQL : drop table if exists team Hibernate: drop table if exists team 2023-06-26 17:02:53.275 DEBUG 16528 --- [ main] org.hibernate.SQL : create table hello ( id bigint not null, primary key (id) ) engine=InnoDB Hibernate: create table hello ( id bigint not null, primary key (id) ) engine=InnoDB 2023-06-26 17:02:53.286 DEBUG 16528 --- [ main] org.hibernate.SQL : create table hibernate_sequence ( next_val bigint ) engine=InnoDB Hibernate: create table hibernate_sequence ( next_val bigint ) engine=InnoDB 2023-06-26 17:02:53.296 DEBUG 16528 --- [ main] org.hibernate.SQL : insert into hibernate_sequence values ( 1 ) Hibernate: insert into hibernate_sequence values ( 1 ) 2023-06-26 17:02:53.297 DEBUG 16528 --- [ main] org.hibernate.SQL : create table member ( member_id bigint not null, age integer not null, username varchar(255), team_id bigint, primary key (member_id) ) engine=InnoDB Hibernate: create table member ( member_id bigint not null, age integer not null, username varchar(255), team_id bigint, primary key (member_id) ) engine=InnoDB 2023-06-26 17:02:53.309 DEBUG 16528 --- [ main] org.hibernate.SQL : create table team ( id bigint not null, name varchar(255), primary key (id) ) engine=InnoDB Hibernate: create table team ( id bigint not null, name varchar(255), primary key (id) ) engine=InnoDB 2023-06-26 17:02:53.317 DEBUG 16528 --- [ main] org.hibernate.SQL : alter table member add constraint FKcjte2jn9pvo9ud2hyfgwcja0k foreign key (team_id) references team (id) Hibernate: alter table member add constraint FKcjte2jn9pvo9ud2hyfgwcja0k foreign key (team_id) references team (id) 2023-06-26 17:02:53.342 INFO 16528 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2023-06-26 17:02:53.351 INFO 16528 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2023-06-26 17:02:53.538 WARN 16528 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2023-06-26 17:02:54.098 INFO 16528 --- [ main] study.querydsl.QuerydslBasicTest : Started QuerydslBasicTest in 3.391 seconds (JVM running for 4.357) 2023-06-26 17:02:54.207 INFO 16528 --- [ main] o.s.t.c.transaction.TransactionContext : Began transaction (1) for test context [DefaultTestContext@424fd310 testClass = QuerydslBasicTest, testInstance = study.querydsl.QuerydslBasicTest@4504a4ed, testMethod = startQuerydsl@QuerydslBasicTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1a45193b testClass = QuerydslBasicTest, locations = '{}', classes = '{class study.querydsl.QuerydslApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@1e13529a, org.springframework.boot.test.autoconfigure.properties .PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@93081b6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@16c069df, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7c3fdb62, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@4d6025c5, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@80ec1f8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@250e8712]; rollback [true] 2023-06-26 17:02:54.308 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.328 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.355 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.356 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.359 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.359 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.362 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.363 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.365 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.365 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.367 DEBUG 16528 --- [ main] org.hibernate.SQL : select next_val as id_val from hibernate_sequence for update Hibernate: select next_val as id_val from hibernate_sequence for update 2023-06-26 17:02:54.368 DEBUG 16528 --- [ main] org.hibernate.SQL : update hibernate_sequence set next_val= ? where next_val=? Hibernate: update hibernate_sequence set next_val= ? where next_val=? 2023-06-26 17:02:54.409 INFO 16528 --- [ main] o.s.t.c.transaction.TransactionContext : Rolled back transaction for test: [DefaultTestContext@424fd310 testClass = QuerydslBasicTest, testInstance = study.querydsl.QuerydslBasicTest@4504a4ed, testMethod = startQuerydsl@QuerydslBasicTest, testException = java.lang.NullPointerException, mergedContextConfiguration = [WebMergedContextConfiguration@1a45193b testClass = QuerydslBasicTest, locations = '{}', classes = '{class study.querydsl.QuerydslApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@1e13529a, org.springframework.boot.test.autoconfigure.properties .PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@93081b6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@16c069df, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7c3fdb62, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@4d6025c5, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@80ec1f8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]] java.lang.NullPointerException at study.querydsl.QuerydslBasicTest.startQuerydsl( QuerydslBasicTest.java:57 ) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:62 ) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:43 ) at java.base/java.lang.reflect.Method.invoke( Method.java:566 ) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod( ReflectionUtils.java:725 ) at org.junit.jupiter.engine.execution.MethodInvocation.proceed( MethodInvocation.java:60 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed( InvocationInterceptorChain.java:131 ) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept( TimeoutExtension.java:149 ) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod( TimeoutExtension.java:140 ) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod( TimeoutExtension.java:84 ) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0( ExecutableInvoker.java:115 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0( ExecutableInvoker.java:105 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed( InvocationInterceptorChain.java:106 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed( InvocationInterceptorChain.java:64 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke( InvocationInterceptorChain.java:45 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke( InvocationInterceptorChain.java:37 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke( ExecutableInvoker.java:104 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke( ExecutableInvoker.java:98 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7( TestMethodTestDescriptor.java:214 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod( TestMethodTestDescriptor.java:210 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute( TestMethodTestDescriptor.java:135 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute( TestMethodTestDescriptor.java:66 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:151 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at java.base/java.util.ArrayList.forEach( ArrayList.java:1541 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll( SameThreadHierarchicalTestExecutorService.java:41 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:155 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at java.base/java.util.ArrayList.forEach( ArrayList.java:1541 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll( SameThreadHierarchicalTestExecutorService.java:41 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:155 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.submit( SameThreadHierarchicalTestExecutorService.java:35 ) at org.junit.platform.engine.support .hierarchical.HierarchicalTestExecutor.execute( HierarchicalTestExecutor.java:57 ) at org.junit.platform.engine.support .hierarchical.HierarchicalTestEngine.execute( HierarchicalTestEngine.java:54 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:107 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:88 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0( EngineExecutionOrchestrator.java:54 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams( EngineExecutionOrchestrator.java:67 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:52 ) at org.junit.platform.launcher.core.DefaultLauncher.execute( DefaultLauncher.java:114 ) at org.junit.platform.launcher.core.DefaultLauncher.execute( DefaultLauncher.java:86 ) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute( DefaultLauncherSession.java:86 ) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute( SessionPerRequestLauncher.java:53 ) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs( JUnit5IdeaTestRunner.java:57 ) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute( IdeaTestRunner.java:38 ) at com.intellij.rt.execution.junit.TestsRepeater.repeat( TestsRepeater.java:11 ) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs( IdeaTestRunner.java:35 ) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart( JUnitStarter.java:235 ) at com.intellij.rt.junit.JUnitStarter.main( JUnitStarter.java:54 ) 2023-06-26 17:02:54.428 INFO 16528 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2023-06-26 17:02:54.430 INFO 16528 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2023-06-26 17:02:54.443 INFO 16528 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. Process finished with exit code -1 </code> [질문 내용] QType 활용 2:22초에서 강사님처럼 리팩토링 후 코드 실행시 NullPointer Exception이 발생합니다. 구글 파일 링크입니다. https://drive.google.com/drive/folders/1FxQskkAngeLJcGPtmKUoj-XCmnxm0MVa?usp=sharing
2023-06-26T08:01:39.741Z
댓글 1
좋아요 0
조회수 670
해결됨
실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
p6spy releases를 확인해보면 1.9.0부터 Spring boot 3을 지원한다고 되어있고 테스트시 로그가 안뜹니다. 다른 질문에서보니 해당 버전이 메이븐에서만 지원되어서 그런 듯 합니다. 그래서 바로 아래 버전인 1.8.1을 사용해서 정상적으로 로그가 뜨는 것을 확인했습니다. 그래서 앞으로 최신 버전으로 했을때 안뜬다면 버전을 내려보시면 좋을 것 같습니다.
java spring 웹앱 spring-boot jpa
김주영
2023-06-26T04:50:10.588Z
댓글 1
좋아요 3
조회수 828
미해결
Practical Testing: 실용적인 테스트 가이드
학습 관련 질문을 남겨주세요. 어떤 부분이 고민인지, 무엇이 문제인지 상세히 작성하면 더 좋아요! 먼저 유사한 질문이 있었는지 검색해 보세요. 서로 예의를 지키며 존중하는 문화를 만들어가요. 안녕하세요. 강의를 열심히 보고 있는 수강자입니다. 다름이 아니라 이번 강의를 보면서 궁금한 점이 있는데요! LocalDateTime을 인자값으로 전달받아 단위테스트하기 좋게 리팩토링하셨는데, 나중에 createOrder를 호출하는 객체의 통합테스트 를 진행할때는 시간에 대한 테스트코드를 어떻게 처리하는지 궁금합니다. 예를 들어 CafeKioskRunner에서 main 메서드를 통합 테스트한다고 했을 때 시간에 따라 createOrder에서 성공 또는 exception이 발생할 것 같아서 이것에 대한 통합테스트를 어떻게 처리하는지 궁금합니다. 감사합니다.
spring tdd jpa mockito 소프트웨어-테스트 junit5
drrg9211
2023-06-25T11:50:40.520Z
댓글 1
좋아요 0
조회수 544
미해결
Practical Testing: 실용적인 테스트 가이드
평소에도 기록하는 습관이 있어 개발자로서 학습을 진행하거나 개발자로서 무언가 했던 행동들을 포스팅하여 기록해나가고 있는 신입개발자입니다. 혹시 강의 관련해서 수강한 내용을 바탕으로 강의 출처 및 링크 남기고 포스팅을 해도 되는지 질문 드립니다. 강의 내에서 사용한 이미지나, 코드 같은 것들은 사용하지 않고 테스트에 관련되어 강의 해주신 개념이나, 샘플 소스는 따로 공부한 내용을 바탕으로 제작하여 포스팅 할 예정입니다. 불가능하다면 노션으로 기록하여 PDF 보관할 예정입니다.
spring tdd jpa mockito 소프트웨어-테스트 junit5
mag1c
2023-06-24T14:24:22.371Z
댓글 1
좋아요 0
조회수 305
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요 선생님! 51:56 쯤에 쓰시는 일정범위로 스크롤하시면서 select 하는 단축키가 어떤 건지 여쭤보고 싶습니다! 강의 화면에 단축키가 안 뜨고, Intellij Keymap 에서 Selection 관련해서 계속 찾아봤는데도 잘 안 보이네요 🥲 좋은 강의 감사드립니다 :)
spring tdd jpa mockito 소프트웨어-테스트 junit5
동해물과백두산이마르고닳도록
2023-06-24T13:09:50.136Z
댓글 1
좋아요 0
조회수 661
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요 선생님, 먼저 좋은 강의 감사드립니다. 로컬환경과 테스트 환경을 별도로 관리해주기 위해서, test 프로파일을 사용하는 것은 이해했습니다. 그런데, 이렇게 되면 모든 클래스에 ActiveProfiles 를 붙여줘야하니 다소 번거로울 것 같습니다. 제가 생각한 방법으로는 SpringBootTest 와 ActiveProfiles 를 묶는 어노테이션을 별도로 만들고, 만든 어노테이션을 이용해볼 것 같습니다. 혹시 ActiveProfiles 를 대체하기 위한 또 다른 방법은 어떤 것들이 있을까요? 좋은 강의 감사드립니다 :)
spring tdd jpa mockito 소프트웨어-테스트 junit5
동해물과백두산이마르고닳도록
2023-06-23T07:56:33.931Z
댓글 2
좋아요 0
조회수 785
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요. "private 메서드 테스트는 어떻게 하나요?" 강의를 들으며 객체의 책임 분리에 대하여 질문드릴 것이 있습니다. 객체의 책임 분리를 위해 별도의 Class를 만들고 객체를 생성해서 해당 객체에게 특정 책임을 부여하려면 결국에 별도의 Class를 만들어야 한다는 것이 전제될텐데요. 현재 제가 일하는 곳에서 대표님이 Class가 많이 늘어나게 되면 유지보수가 어렵게 되고 코드가 지저분해질 수 있다고 하신 적이 있습니다. 전 객체지향 관점에서 한 객체가 모든 걸 다 하고 한 메서드가 너무 많은 행위를 하는 것이 좋지 않다고 생각하는데 우빈님은 혹시 제가 들은 대표님의 말씀에 대해 어떻게 생각하시는지 궁금합니다.
spring tdd jpa mockito 소프트웨어-테스트 junit5
비가싫어요
2023-06-23T07:46:36.817Z
댓글 1
좋아요 0
조회수 536
해결됨
Practical Testing: 실용적인 테스트 가이드
학습 관련 질문을 남겨주세요. 어떤 부분이 고민인지, 무엇이 문제인지 상세히 작성하면 더 좋아요! 먼저 유사한 질문이 있었는지 검색해 보세요. 서로 예의를 지키며 존중하는 문화를 만들어가요. 질문 Order Entity가 상속 받는 BaseEntity에 createdDateTime 컬럼이 있음에도 registerdDateTime 컬럼을 추가하는 이유는 무엇인가요? 외부결제API에서 제공하는 결제일시를 저장하기 위함인가요?
spring tdd jpa mockito 소프트웨어-테스트 junit5
깨비깨비
2023-06-22T06:13:31.974Z
댓글 1
좋아요 0
조회수 447
해결됨
Practical Testing: 실용적인 테스트 가이드
이제 막 java, spring, mysql , 프론트 부분 기초적인 부분 공부를 끝마친 학생입니다. 항상 테스트 코드의 중요성을 많은 커뮤니티에서 봐오고 강조하는 분들이 많아서 언젠간 배워야겠다 싶은 찰나에 수강 결제를 미리 하게 되었습니다. 혹시 선생님 수업을 듣기 전, 미리 좀 더 배워둬야 하거나 알아둬야 하는 부분이 있을까요 ?
spring tdd jpa mockito 소프트웨어-테스트 junit5
ㆍ
2023-06-22T00:43:20.702Z
댓글 2
좋아요 1
조회수 357
해결됨
실전! 스프링 데이터 JPA
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 안녕하세요. 카운트 쿼리 분리 부분을 듣는 도중에 카운트 쿼리에 LEFT JOIN이 사용되는 결과를 확인하기 위해 다음처럼 코드를 작성하였습니다. public interface MemberRepository extends JpaRepository<Member, Long> { @Query(value = "select m from Member m left join m.team t") Page<Member> findByAge(int age, Pageable pageable); ... } @Test public void paging() throws Exception { //given memberRepository.save(new Member("member1", 10)); memberRepository.save(new Member("member2", 10)); memberRepository.save(new Member("member3", 10)); memberRepository.save(new Member("member4", 10)); memberRepository.save(new Member("member5", 10)); //when PageRequest pageRequest = PageRequest.of(0, 3, Sort.by(Sort.Direction.ASC, "username")); Page<Member> page = memberRepository.findByAge(10, pageRequest); //then List<Member> content = page.getContent(); assertThat(content.size()).isEqualTo(3); assertThat(page.getTotalElements()).isEqualTo(5); assertThat(page.getNumber()).isEqualTo(0); assertThat(page.getTotalPages()).isEqualTo(2); assertThat(page.isFirst()).isTrue(); assertThat(page.hasNext()).isTrue(); } 그런데 결과는 강의와는 달리 카운트 쿼리에 LEFT JOIN 이 사용되지 않았고, 심지어 JPQL select m from Member m left join m.team t 을 @Query에 작성했음에도 조회 쿼리도 LEFT JOIN을 사용하지 않은 것을 확인했습니다. 이후 스프링 부트 3 이하 버전에서 동일한 코드로 실행해보니 강의와 동일한 결과를 얻을 수 있었습니다. 스프링 부트 3 부터 적용된 스프링 데이터 JPA 에서는 이러한 부분의 최적화를 자동으로 제공하는 것일까요?
조약돌
2023-06-21T12:43:38.888Z
댓글 1
좋아요 1
조회수 773
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요 선생님. 빌더를 사용하시는 것을 보고 흥미가 동해 질문남깁니다! 선생님께서는 예제의 경우 대부분 생성자를 private으로 막아두고 빌더를 통해서만 객체를 생성하시는 것 같습니다. 저는 필드 개수가 많아도 public 생성자로 열어두는 편인데, 그 이유는 어떤 인자를 전달해야할지 인텔리제이의 힌트로 알아채기도 편하고 필드가 null 일 수도 있는 경우 객체를 생성할 때 명시적으로 null 이 보이는게 낫다 라고 생각해서입니다. null을 명시적으로 인자로 전달하는 것이 불편하다면 텔레스코핑을 통해 생성자를 조금 더 만들어두기도 합니다 :) 물론 빌더 패턴을 사용하면 이런 코드들이 전부(?) 사라지기는 하지만, 이 외에 빌더로 객체 생성을 강제하는 것에 대한 장점 이 있는지 궁금합니다! 또, 선생님만의 빌더랑 생성자 선택 기준 이 따로 있을까요? 마지막으로 실무에서도 자주 사용하시는지 궁금합니다. 좋은 강의 감사드립니다 :)
spring tdd jpa mockito 소프트웨어-테스트 junit5
동해물과백두산이마르고닳도록
2023-06-21T09:11:17.780Z
댓글 2
좋아요 4
조회수 1205
미해결
즐거운 자바
안녕하세요. 백엔드 개발자 희망하고 있습니다. 자바 독학 공부 시작했는데 기본문법 예제들은 혼자 짤 수 있는데 객체지향/3 로또 부분부터 어렵네요. 구구단, 별찍기 하다가 로또 구현할 수 있을때까지 공부 방법이 궁금합니다. ㅠ.ㅠ 자바 공부 방법 알려주세요 ㅠㅠㅠ 지금은 강사님 강의 보고 이해가 부족하다는 부분 이론서 보면서 나가고있습니다. 이론서에 나와있는 문제들도 타이핑 하면서 진행하구 있습니다. 길게 코드 작성할 수 있을때까지 자바 공부 방법 알려주세요.
2023-06-21T07:35:32.529Z
댓글 2
좋아요 1
조회수 1724
미해결
실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] plugins { id 'org.springframework.boot' version '2.6.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' ext["hibernate.version"] = " 5.6.5.Final " configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'javax.validation:validation-api' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5' //JdbcTemplate 추가 //implementation 'org.springframework.boot:spring-boot-starter-jdbc' //MyBatis 추가 implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0' //JPA, 스프링 데이터 JPA 추가 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' //Querydsl 추가 implementation 'com.querydsl:querydsl-jpa' annotationProcessor "com.querydsl:querydsl-apt:$ { dependencyManagement.importedProperties['querydsl.version'] } :jpa" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" //H2 데이터베이스 추가 runtimeOnly 'com.h2database:h2' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //테스트에서 lombok 사용 testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' } tasks.named('test') { useJUnitPlatform() } //querydsl 추가 //def querydslDir = '$buildDir/generated' def querydslDir = "src/main/generated" //clean { // delete file(generated) //} querydsl { library = "com.querydsl:querydsl-apt" jpa = true querydslSourcesDir = querydslDir } sourceSets { main { java { srcDirs = ['src/main/java', querydslDir] } } } compileQuerydsl { options.annotationProcessorPath = configurations.querydsl } configurations { querydsl.extendsFrom compileClasspath } 강사님이 올려주신 내용 + 구글링 + 직접 수정했습니다. 간혹, 빌드는 되는데 generated 파일에 QClass 안보이시는 분들은 queryDsl 저장되는 경로에 $buildDir 대신 'src/main/'으로 해보세요
henn36
2023-06-19T13:47:48.635Z
댓글 1
좋아요 4
조회수 1263
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요 강의 잘 보고 있습니다. 테스트에 대해 파편화 된 지식을 학습자들이 원하는 내용으로 잘 만들어 낸 좋은 강의라고 생각합니다. 현재 저희 팀음 통합 테스트 및 인수 테스트를 할 때 미리 쿼리문을 작성해두고 이를 @SqlGroup과 @Sql을 활용하여 데이터를 삽입해주고 있습니다. 이 경우 강의 내에서 말씀하신 것 처럼 스키마 변경이 생길때마다 모든 쿼리를 찾아 수정해야하는 번거로움이 있습니다. 하지만 매 케이스마다 세팅을 하기에는 연관된 5개~10개의 테이블에 대한 데이터 수십개를 매번 세팅해줘야 하는 것이 어렵게 느껴집니다. 이때 repository를 계층을 넘어서까지 임포트 해서 사전 데이터 삽입을 해줘야 하는가 궁금하구요. 또한 모든 객체에 Builder를 개방하면 그나마 할만하겠지만 아닌 경우 객체가 제공하는 제한적으로만 생성이 가능할텐데, 리플렉션이라도 써야하는건지 너무 걸리는 경우가 많습니다. 다소 두서 없고 여러 질문을 한번에 했지만 제가 어떤 어려움을 겪는지는 전달 되었으리라 생각합니다.
spring tdd jpa mockito 소프트웨어-테스트 junit5
타태
2023-06-18T05:42:35.613Z
댓글 2
좋아요 2
조회수 556
미해결
실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
주문 서비스 개발 부분 강의를 듣다가 궁금한 점이 있어 질문드립니다. 주문 취소(OrderService.cancelOrder) 부분에서order.cancel() 만 작성하면 JPA 특징으로 인해, 데이터 업데이트 관련 쿼리 로직 없이 자동으로 업데이트 된다고 하셨는데요. 주문 생성(OrderService.order)의 EntityManager 가 사용된 orderRepository.save (order); 와 혼동이 와서 질문 남깁니다. 주문 취소 order.cancel() 메서드를 타면서 엔티티의 값(status, count 등) 변경 내역이 자동으로 업데이트 되는 것이라고 하면, 주문 생성도 Order.createOrder(member, delivery, orderItem); 를 타면서 엔티티의 값들을 설정하기 때문에 orderRepository.save (order); 를 사용하지 않아도 되는게 아닌가 라는 생각이 듭니다. 제가 JPA 를 잘 몰라서 혼란이 오는 것 같은데.. 쿼리는 직접 작성하지 않아도 업데이트/저장/삭제 등 DB 조작이 일어나려면 EntityManager 를 통해야 된다고 생각하고 있었습니다. 주문 취소는 EntityManager 없이 업데이트 되고, 주문 생성은 EntityManager의 persist() 를 사용해서 저장하는 것 이 2가지 차이점에 대해서 설명 부탁드립니다! 감사합니다 :)
java spring 웹앱 spring-boot jpa
빈빈
2023-06-17T10:01:09.362Z
댓글 1
좋아요 2
조회수 510
해결됨
실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 현재 스프링 부트 3.1 로 강의를 따라가고 있습니다. default_batch_fetch_size:10 을 설정해서 나가는 쿼리가 줄어드는 것을 확인했습니다만, 쿼리가 두 개가 아니고 총 세 개가 나왔습니다. 023-06-13T23:24:02.666+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select o1_0.order_id, d1_0.delivery_id, d1_0.city, d1_0.street, d1_0.zipcode, d1_0.status, m1_0.memeber_id, m1_0.city, m1_0.street, m1_0.zipcode, m1_0.name, o1_0.order_date, o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset ? rows fetch first ? rows only 2023-06-13T23:24:02.676+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242676 | took 2ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select o1_0.order_id,d1_0.delivery_id,d1_0.city,d1_0.street,d1_0.zipcode,d1_0.status,m1_0.memeber_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name,o1_0.order_date,o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset ? rows fetch first ? rows only select o1_0.order_id,d1_0.delivery_id,d1_0.city,d1_0.street,d1_0.zipcode,d1_0.status,m1_0.memeber_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name,o1_0.order_date,o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset 0 rows fetch first 100 rows only; 2023-06-13T23:24:02.681+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select o1_0.order_id, o1_0.order_item_id, o1_0.count, o1_0.item_id, o1_0.order_price from order_item o1_0 where array_contains(?,o1_0.order_id) 2023-06-13T23:24:02.689+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242689 | took 0ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select o1_0.order_id,o1_0.order_item_id,o1_0.count,o1_0.item_id,o1_0.order_price from order_item o1_0 where array_contains(?,o1_0.order_id) select o1_0.order_id,o1_0.order_item_id,o1_0.count,o1_0.item_id,o1_0.order_price from order_item o1_0 where array_contains('ar2: ARRAY [CAST(1 AS BIGINT), CAST(2 AS BIGINT), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]',o1_0.order_id); 2023-06-13T23:24:02.690+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select i1_0.item_id, i1_0.dtype, i1_0.category_item_id, i1_0.name, i1_0.price, i1_0.stock_quantity, i1_0.author, i1_0.isbn, i1_0.artist, i1_0.etc from item i1_0 where array_contains(?,i1_0.item_id) 2023-06-13T23:24:02.691+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242691 | took 0ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select i1_0.item_id,i1_0.dtype,i1_0.category_item_id,i1_0.name,i1_0.price,i1_0.stock_quantity,i1_0.author,i1_0.isbn,i1_0.artist,i1_0.etc from item i1_0 where array_contains(?,i1_0.item_id) select i1_0.item_id,i1_0.dtype,i1_0.category_item_id,i1_0.name,i1_0.price,i1_0.stock_quantity,i1_0.author,i1_0.isbn,i1_0.artist,i1_0.etc from item i1_0 where array_contains('ar3: ARRAY [CAST(1 AS BIGINT), CAST(2 AS BIGINT), CAST(3 AS BIGINT), CAST(4 AS BIGINT), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]',i1_0.item_id); 수강 중에 제가 따라 작성한 코드를 스프링부트 2.4.1에 그대로 옮겨보니 강의 내용대로 where in 쿼리가 나오는 것을 확인했습니다. 스프링부트 버전 차이에서 나오는 쿼리가 달라진 것 같은데, 제 생각이 맞을까요? 답변 확인 : 빠르게 답변해주셔서 감사합니다!! 덕분에 array_contains 로 최적화된 이유를 쉽게 이해할 수 있었습니다. (Hibernate에서 최적화를 했었었군요!) 아 그리고 강의 내용에서 쿼리 세 개 나온다는 것을 확인했습니다(잘못 본 것에 대해 질문글에서 수정을 해놨어야 했는데 빼놓지 않았었네요 ㅠㅠ) 다시 한번 상세한 답변 정말 감사드립니다.
말랑한참깨
2023-06-13T14:26:41.598Z
댓글 1
좋아요 1
조회수 1928
해결됨
Practical Testing: 실용적인 테스트 가이드
안녕하세요. 우빈님 양질의 강의 제공해주셔서 감사의 말씀드립니다. 강의를 듣던 도중 실무에서는 어떻게 해결을 할까? 🤔 라는 궁금증이 생겨 질문 드립니다. 만약에 테스트 코드 작성시에 setup해야 할 데이터가 대용량 이라면 실무에서는 주로 어떤 방식으로 테스트 코드를 작성하여 해결하나요? 감사합니다.
spring tdd jpa mockito 소프트웨어-테스트 junit5
개발하는쿼카
2023-06-12T07:48:58.315Z
댓글 2
좋아요 0
조회수 682