묻고 답해요
169만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
DB저장관련 질문입니다
안녕하세요하이버네이트는 변경되는 값을 캐쉬에 저장해놨다가 persist나 flush신호가 있을때 db에 값을 업데이트한다고 알고있는데요,따로 flush를 주지않으신거같은데 addStock등을 활용해서 값을 변경했을때 DB에서 자동으로 플러쉬가 나가는건가요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
JPA에서는 Insert into select는 사용할수 없는건가요?
안녕하세요 강사님 jpa 강의를 들으면서 insert into select을 하고 싶은데, 구글링을 해도 정보가 없는데, jpa에서는 무조건 insert만 할수 있는 건가요 ?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
OrderItem 클래스 비즈니스 로직 & 조회로직 질문
안녕하세요 복습하면서 궁금한 점이 생겼는데요 OrderItem 클래스에서 만든 비즈니스 로직과 조회로직에서 getItem, getOrderPrice 그리고 getCount 사용하셨는데 get없이 그냥 해도 같은 결과를 얻었습니다. 혹시 get을 사용하신 이유가 있으신가요 ?
-
미해결스프링 핵심 원리 - 기본편
응원의 수강평 올리려고 하는데, 어디에 올려야하나요?! 김영한 강사님 화이팅!
응원의 수강평 올리려고 하는데, 어디에 올려야하나요?! 김영한 강사님 화이팅!
-
미해결윤재성의 만들면서 배우는 Spring MVC 5
DB가 mysql일때는 @SelectKey 와 addContentInfo의 @Insert문은 어떻게 구성하나요
안녕하세요? 23분 부터의 내용입니다. DB가 mysql일때는 @SelectKey 와 addContentInfo의 @Insert문은 어떻게 구성하나요? 구글링해도 잘 모르겠습니다...ㅠㅜ @selectkey 쿼리내용을 SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = "databaseName" AND TABLE_NAME = "tableName" 로 수정하는게 맞는지 궁금합니다..양질의 강의 감사히 보고있습니다!
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
리포지토리 반환값을 List 에서 Stream 으로 바꿔 받는 과정에 문제가 생겨 남겨보아요
안녕하세요 김영한강사님.알찬 강의 열심히 응용중에 문제가 생겼습니다. 다음처럼 Repository 반환값을 List<엔티티> 에서 Stream<엔티티> 로 했을 경우 Controller 에서 엔티티를 받아오지 못하더라구요 MemberRepository . findAll() ---> Stream<Member> 반환 em.createQuery("select m from Member m", Member.class) .getResultStream() // MemberController 의 addAttr 직전 Stream을 List변환 memberService.findMembers().collect(Collectors.toList()); error1 : The object is already closed [90007-199]error2 : could not advance using next()직감으로는, 닫혔다는것이.. Stream 이라 불변객체여서 변경이 안된다는 이야기로 보이는데List<Member> 로 싹 바꿔야 되나 고민하고 있습니다. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- LIst<엔티티> 로 바꾸니 문제없이 출력이 되었습니다. 원인이 createQeury().getResultStream() 이었는데결국 Proxy 를 Stream 에 담은 상태로불변성이 보장되어서하이버네이트가 내부에 RealEntity 값을 심어야 되는데이작업을 할 수 없으니 애러가 나는것이 맞는건가요?맞다면, Stream은 어느시점에 사용하는것이 좋은가요..?
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
repository랑 service 개념 질문입니다.
1. 제가 DAO라는 방식으로 먼저 배워서 repository를 DAO라고 생각하고 이해하고 있는데요. 이게 맞는건가요? 2. repository로 바로 비즈니스로직을 수행을 해도 되는데 service로 나눠준 이유는 사용자들이 동시에 사용할 수 있게 하기 위한거라고 알고 있는데 이게 맞는건가요?
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
빌드가 안되요
기존 JDK버전을 11버전으로 바꿔서 빌드했는데 정확한 원인을 모르겠습니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
테스트 exception 관련 질문 입니다.
안녕하십니까 선생님의 강의 정말 유익하게 잘 보고 있습니다. 다름이아니라 상품주문 test 를 하게되면 ==== 오류 org.springframework.dao.InvalidDataAccessApiUsageException: id to load is required for loading; nested exception is java.lang.IllegalArgumentException: id to load is required for loading 이런식으로 납니다.그래서 id가 자동으로 생성이 안되는내용이라서 @GenereatedValue 가 이미 Item 에 id 에 선언되어있고 혹시나 해서 setId로 id 값 지정후 해보니 그다음으로는 == 오류 전문 java.lang.NullPointerException at jpabook.jpashoop.service.OrderService.order(OrderService.java:41) at jpabook.jpashoop.service.OrderService$$FastClassBySpringCGLIB$$f6e85b24.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at jpabook.jpashoop.service.OrderService$$EnhancerBySpringCGLIB$$ac50f3a2.order(<generated>) at jpabook.jpashoop.service.OrderServiceTest.상품주문(OrderServiceTest.java:44) 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:686) 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$6(TestMethodTestDescriptor.java:212) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) 이런식으로 NullPointEception 이 일어납니다.혹시 이렇게 되면 item class가 문제인지 또는 service 와 repository 문제인지 혹시 알고싶습니다.
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
라이브러리 인식 오류
이클립스 환경인데요, build과정에서 오류가나서 프로젝트를 지우고 다시 불러왔는데 아예 gradle 라이브러리 인식을 못합니다.. ㅠㅠ 구글링을 엄청했는데도 못고쳐서 진도를 못나가고 있어요 The import org.springframework cannot be resolved 오류이름은 이거에요
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
@Transactional 애노테이션 질문
@Transactional 애노테이션만 붙이면 jpa기본편에서 배웠던 대로 해당 메소드를 아래와 같이 감싸서 실행하게 되는건가요? tx.begin() try { --- 메소드 실행 --- tx.commit() } catch (Exception e) { tx.rollback() } finally { em.close() } emf.close()
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
안녕하십니까? 도메인 설계시 인터페이스, 추상클래스 에 대한 의견을 듣고 싶습니다.
안녕하십니까? 강의 영상 모두 결제해서 잘 보고 있습니다. 바로 본론부터 말씀 드리면, 회사에서 여러개의 프로젝트를 준비하고 있고 그중 자주 쓰이는 공통적인 기능을 ( 회원, 게시판 등 ) 만들어 놓고 프로젝트마다 재활용하여 시간을 단축하자는 의견이 나왔습니다. 그래서 JPA 에서 사용하는 entity 도 인터페이스와 추상클래스를 사용해서 설계를 해보라고 해서 진행중에 있습니다. 들어가기 앞서, 스프링 프로젝트의 코드를 살펴보면 인터페이스를 잘 사용해서 설계를 잘 했다고 생각하고 있습니다.그러나 데이터베이스와 직접적인 연관이 없는 코드라서 자유롭게 쓸수 있었던것 같은데요. JPA 를 쓰고 있는 입장에서 인터페이스와 추상클래스를 사용해서 다형성을 구현할려고 할때마다 한계에 자꾸 봉착하는 느낌이 듭니다. 결국 도메인 클래스는 CRUD 가 중요한데, 인터페이스로는 실제 구현된 클래스가 뭔지 알수 없어 사용하기가 난감합니다. Item 과 Book 과 같이 강하게 결합 하는것에 대해서는 어느정도 수긍이 갑니다만, 거의 대부분은 그렇게 강하게 연결되는 경우가 잘 없는거 같아서요. 인터페이스를 쓰는경우도 잘 못본거 같습니다. 실무에서는 인터페이스와 추상클래스를 어느 정도 까지 사용하는지궁금합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
JdbcMemberRepository에서 import 문제
선생님 안녕하세요. 우선 정말 이 수업을 개설해 주셔서 정말정말 감사하다는 말씀 드립니다. 프로젝트 수업으로 스프링 프레임워크에서 스트레스를 엄청 받다가 선생님의 강의를 듣고 한줄기 희망이 생겼습니다!!! 지금 DB 파트 강의에서 순수 JDBC 듣는 중인데, 원래는 오라클 SQL을 사용하려다 import 하는 부분에서 막히길래, 역시 강의와 다른 걸 쓰려니 힘들구나 싶어서ㅜㅜ 우선은 그냥 수업에서 사용하시는 H2로 다시 시도하고 원리를 좀 깨친 다음에 오라클로 재시도 하려 했습니다만.... 결국은 똑같은 곳에서 문제가 생기길래 이렇게 질문을 드립니다. H2에서 DB 생성하고, build.gradle에서 의존성 주입했고, application.properties에 url, driver-class-name까지 설정은 완료한 상태입니다. 그러고나서 JdbcMemberRepository 코드를 작성했는데, 이상하게 이 부분만 import에서 오류가 생깁니다. import org.springframework.jdbc.datasource.DataSourceUtils;(밑줄 친 부분에 오류가 있다고 빨간 줄이 생김) 에러메시지는 "The import org.springframework.jdbc cannot be resolved" 라고 뜨고, 클래스를 새로 생성하라는 식으로만 나오고 있습니다 ㅜㅜ 강제로 실행시키면 다음 메시지가 나옵니다. "Description:Parameter 0 of constructor in hello.hellospring.SpringConfig required a bean of type 'javax.sql.DataSource' that could not be found. The following candidates were found but could not be injected: - Bean method 'dataSource' in 'JndiDataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' - Bean method 'dataSource' in 'XADataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager' Action: Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration. " 사용 환경은 윈도10 / Eclipse EE / Spring boot 2.3.3. 입니다.수업을 착실히 들었다고 생각했는데 혹시 설정 같은 걸 빼먹은 게 아닌지 싶은데, 구글링해도 답을 얻을 수 없어 여쭤봅니다. 감사합니다 !!
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
update에대한 질문입니다!
지금은 Book 상품등록, 상품수정의 기능만 한다고 하셨는데 영화와 음반까지 추가하려면 단순히 controller와 service에 메서드들을 추가해서 로직을 짜면 되는건가요? 아니면 메서드를 추가안하고 다른 방법이 있을까요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
sequence 변수에 대하여 너무 궁금한 점이있습니다.
안녕하세요. 김영한 강사님. 이번 강의를 듣던 도중 실무 이야기를 몇번 하셨는데요. sequence 변수에 대해 궁금하 점이 생겼습니다. Member를 save할때마다 id 값을 1씩 증가시켜주는데요. 이건 DB기반이 아니라 메모리 기반이기 때문에 id값을 이렇게 임의로 정해주는 것인가요? 실무에서 DB는 id 값을 auto increment를 주지 않고 이런 식으로 sequence를 올려가며 회원 저장마다 id값을 지정해주는 건가요? 제가 이해한것이 맞다면 서버가 재가동 될때마다 모든 회원 DB를 다 읽어와야 하는 시스템인것 같은데 제가 이해한바가 맞는지요.. 너무 궁금해서 그냥 넘어갈수가 없었습니다. 감사합니다.
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
조회 v3.1에서 to One 관계는 모두 페치 조인하고 나머지 컬렉션은 지연로딩을 유지했을때 다음과 같은 에러가 발생합니다.
좋은 강의 감사합니다. 조회 v3.1에서 to One 관계는 모두 페치 조인하고 나머지 컬렉션은 지연로딩을 유지했을때 다음과 같은 에러가 발생합니다. query specified join fetching, but the owner of the fetched association was not present in the select list 고심하던 중 @Query부분을 value 와 countQuery로 나눠어서 처리 한 결과 정상적으로 조회 됬습니다.(Spring Data Jpa사용) 예) @Query(value = "select u from User u join fetch u.store s", countQuery = "select count(u) from User u") Page<User> findAllUser(Pageable pageable); 꼭 countQuery를 사용해야 하는지 궁금합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
옛날 사람 아닙니다!! ㅠㅠ
공공기관 취직해서 1년 근무했는데 옛날사람들이 쓰는 기술이라고 하는 기술들만 쓰고 있습니다. ㅠㅠ 잘 공부해서 최신사람으로 거듭나겠습니다! 응원해주세요... 따로 메시지 보내고 싶었는데 찾을수가 없어서 여기 남깁니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
thymeleaf 의 경로를 못찾는다고 나오네요
indx.html을 /src/main/resourcee/static/index.html을 넣어도 못찾네요 hello예제에서는 "template might not exist or might not be accessible by any of the configured Template Resolvers" 로 나오네요 경로가 차이가 있는건지 모르겠습니다. 아래는 grandle 설정입니다 어떤 문제가 있는건지 모르겠습니다. plugins { id 'org.springframework.boot' version '2.1.16.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java'}group = 'jpabook'version = '0.0.1-SNAPSHOT'sourceCompatibility = '1.8'configurations { compileOnly { extendsFrom annotationProcessor }}repositories { mavenCentral()}dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test'}
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
post vs put
안녕하세요. 보통 리소스를 수정하는데 put 메서드를 사용한다고 알고 있는데, post를 사용한 이유 같은게 있나요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
Category 계층 구조를 보고 질문드립니다.
안녕하세요. 영한님 강의 잘 듣고 있습니다. 감사합니다. Category Entity에서 parent와 child 만드는 것을 보고 게시판에서 댓글과 대댓글 관계를 생각해보았는데 댓글 Entity에서 대댓글을 List로 담고 똑같은 계층구조로 구현하는게 객체지향적인 설계가 맞을까요?