묻고 답해요
141만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
Slf4j 모듈 찾기 오류
[질문 내용]여기에 질문 내용을 남겨주세요.이번에 인텔리제이를 처음 사용합니다.모듈안에서 찾을 수 없다고 해서 pom.xml에서 의존성을 선언하였습니다. 의존성을 선언해도 오류가 발생됩니다...(구글링을 통해 버전 확인을 해봤지만 찾지 못함)<질문 요약>1) Slf4j 버전 확인하는 법2) pom.xml 에서 dependcy가 밑줄 이유, 해결방법3) 의존성 선언을 하였지만 선언 실패감사합니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
섹션1 마지막 강의 TEST 가 안 돌아갑니다..!
=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)MemberRepositorytest이고application.yml 입니다. 아래와같이 오류가 계속 뜹니다.. 아무리 해도 해결이 안 됩니다 ㅜㅜㅜ 도와주실수있으신가요java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) 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:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbConnection' defined in jpabook.jpashop.dbConnection defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: interface org.apache.catalina.User at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:936) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:921) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:136) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90) ... 27 moreCaused by: java.lang.IllegalArgumentException: Not a managed type: interface org.apache.catalina.User at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:583) at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:75) at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:233) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:182) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:165) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:76) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:325) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) at org.springframework.data.util.Lazy.getNullable(Lazy.java:231) at org.springframework.data.util.Lazy.get(Lazy.java:115) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ... 42 more
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
연관 관계 메서드에 관해 질문있습니다.
public void addOrderItem(OrderItem orderItem) { orderItems.add(orderItem); orderItem.setOrder(this); }강사님은 양방향 연결을 해서 연관관계 매서드 작성하셨는데 단방향 연결해서 orderItem에만 @ManyToOne 한 경우에는 어떻게 하나요? 아니면 다대다라서 중간테이블쓴경우에는 무조건 양방향 설정을 해야하나요?
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
OneToMany에서 @JoinColumn(nullable = false, updatable = false)에 대하여
안녕하세요 궁금한 것이 있습니다.JPA에서 @OneToMany를 통한 단방향 연관관계에서 문제로 지적되는 것이 Many쪽의 FK를 update. 하기 위한 추가적인 쿼리 문제인데요. (물론 이것만이 @OneToMany 단방향의 문제는 아닙니다만)이 문제는 @JoinColumn(nullable = false, updatable = false)이라는 설정을 통해 해결할 수 있는 것으로 알고 있습니다.이러면 One을 먼저 insert한 후, Many를 insert할 때 One의 PK를 바탕으로 추가적인 업데이트 쿼리 없이 바로 insert를 해주는걸로 알고 있습니다.근데 "대체 JPA는 왜 이렇게 설계한걸까?" 라는 의문이 듭니다.물론 앞서 말씀드린 방법은 FK가 not nullable이여야하고, FK가 변경되면 안된다는 제약 조건이 들어가야하기 때문에, 모든 상황에서 공통적으로 적용되는 방법은 아닙니다만, 차라리 이런 설정을 default로 하는게 이해하기 더 쉬운 방법아닌가? 라는 생각이 들어서요.FK가 nullable하고, 또 변경될 수 있는 상황은 상대적으로 적은데다가, insert한 컬럼에 FK를 추가해주기 위해 update 쿼리가 나가게 되는 로직은 성능적으로도(드라마틱하진 않지만) 좋지 않고, hibernate를 처음 사용하는 사람은 "대체 왜 이렇게 쿼리가 나가지?"라는 식으로 이해하기 어렵다고 판단이 들거든요.사실 이게 프로그래밍 하는데 중요한 지식은 아니지만.. 그냥 순전히 호기심으로 궁금합니다.
-
해결됨실전! 스프링 데이터 JPA
JpaRepository 구현 관련
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]여기에 질문 내용을 남겨주세요.SimpleJpaRepository가 처음에 생성될 때 entitymanager를 의존성 주입을 받아서 초기화가 됩니다.문제는 전에 강의에서 entitymanager는 트랜색션 하나당 하나를 생성해야 한다고 했던 것이 생각납니다. 문제는 이렇게 처음 초기화할 때 entitymanager를 주입받게되면 한 entitymanager를 스프링 프로그램이 끝날 때 까지 사용하게 되는데 문제가 없는건가요?https://jiwondev.tistory.com/225이런식으로 트랜색션이 끝나고 연결이 끝나도 entitymanager를 유지하면 문제가 생기지 않을까 생각되어 질문드립니다.
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
hello jpa 애플리케이션 개발 오류
자바 17 사용하는데 아래와 같은 오류가 납니다.
-
미해결실전! 스프링 데이터 JPA
스프링 데이터 JPA delete 안되는 이유가 궁금합니다
안녕하세요! 스프링 데이터 JPA를 상속받은 리포지토리를 통해 crud 구현 연습을 하고 있었습니다. 게시판 유저와 유저가 작성한 글을 각각 User, Article 엔티티로 표현했습니다.User의 경우 모든 기능이 정상적으로 작동됩니다.그런데 Article은 삭제가 이루어지지 않는 현상이 발생하고 있습니다.그렇다고 중간에 예외가 발생하는 것도 아니고, 삭제시에는 삭제한 엔티티의 정보를 반환하게끔 설계했는데 멀쩡히 반환이 잘되고 DB에서도 삭제되지 않았습니다.package com.crud.controller.article; import com.crud.constant.MessageConst; import com.crud.dto.Result; import com.crud.entity.User; import com.crud.service.ArticleService; import com.crud.service.UserService; import com.crud.utils.ResultUtils; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/articles") @RequiredArgsConstructor public class ArticleController { private final ArticleService articleService; private final UserService userService; private final MessageConst messageConst; @GetMapping public ResponseEntity<Result<Page<ArticleDTO>>> articles(@ModelAttribute ArticleSearchCond articleSearchCond, @PageableDefault Pageable pageable) { Page<ArticleDTO> page = articleService.findAll(articleSearchCond, pageable); return ResponseEntity.ok().body(ResultUtils.success(page, messageConst.successSearch())); } @GetMapping("/{id}") public ResponseEntity<Result<ArticleDTO>> article(@PathVariable Long id) { ArticleDTO foundArticle = new ArticleDTO(articleService.findById(id)); return ResponseEntity.ok().body(ResultUtils.success(foundArticle, messageConst.successSearch())); } @PostMapping("/save") public ResponseEntity<Result<ArticleDTO>> save(@RequestBody @Validated ArticleSaveDTO saveDTO) { User user = userService.findById(saveDTO.getUserId()); ArticleDTO articleDTO = articleService.save(saveDTO, user); return ResponseEntity.ok().body(ResultUtils.success(articleDTO, messageConst.successSave())); } @PatchMapping("/{id}") public ResponseEntity<Result<ArticleDTO>> update(@PathVariable Long id, @RequestBody ArticleUpdateDTO updateDTO) { ArticleDTO updatedArticle = articleService.update(id, updateDTO); return ResponseEntity.ok().body(ResultUtils.success(updatedArticle, messageConst.successUpdate())); } // 삭제 메서드 호출입니다!!!!!! @DeleteMapping("/{id}") public ResponseEntity<Result<ArticleDTO>> delete(@PathVariable Long id) { ArticleDTO deletedArticle = articleService.delete(id); return ResponseEntity.ok().body(ResultUtils.success(deletedArticle, messageConst.successDelete())); } } package com.crud.service; import com.crud.controller.article.ArticleDTO; import com.crud.controller.article.ArticleSaveDTO; import com.crud.controller.article.ArticleSearchCond; import com.crud.controller.article.ArticleUpdateDTO; import com.crud.entity.Article; import com.crud.entity.User; import com.crud.exception.NoSuchDataException; import com.crud.repository.article.ArticleRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @Transactional @RequiredArgsConstructor public class ArticleService { private final ArticleRepository articleRepository; @Transactional(readOnly = true) public Page<ArticleDTO> findAll(ArticleSearchCond articleSearchCond, Pageable pageable) { return articleRepository.findAll(articleSearchCond, pageable); } @Transactional(readOnly = true) public Article findById(Long id) { return articleRepository.findById(id).orElseThrow(NoSuchDataException::new); } public ArticleDTO save(ArticleSaveDTO saveDTO, User user) { Article article = Article.createArticle(saveDTO, user); Article savedArticle = articleRepository.save(article); return new ArticleDTO(savedArticle); } public ArticleDTO update(Long id, ArticleUpdateDTO updateDTO) { Article article = findById(id); article.update(updateDTO); return new ArticleDTO(article); } // 삭제 메서드입니다!!!!! public ArticleDTO delete(Long id) { // articleRepository.deleteById(id); Article article = findById(id); articleRepository.delete(article); return new ArticleDTO(article); } }컨트롤러가 userService, articleService를 둘다 주입받고 있어서 트랜잭션이 꼬였나하고 userService를 지워보았는데 여전히 삭제는 안되었습니다. 그런데 만약 articleService.delete()의 반환타입을 void로 하여 아무것도 반환안하고(컨트롤러가 반환하는 api의 내용물도 그냥 null로 설정했습니다) 주석처리한 deleteById(id)를 사용해서 id로 바로 지우면 DB에서의 삭제가 이루어졌습니다. 이유를 계속 생각해보고 이거저거 건드려보고있긴한데, 아직까지는 도저히 모르겠습니다.. 리포지토리는 동적검색메서드만 따로 추가되었지, 삭제 메서드는 스프링 데이터 JPA의 delete를 그대로 가져다 쓴것입니다. 혹시 추가적인 코드가 필요하다면 말씀해주세요!
-
미해결실전! 스프링 데이터 JPA
h2 데이터베이스에서 Team table not found 에러 문의
스프링 데이터 JPA의 초기 테스트 파일 실행 시 아래와 같은 에러가 뜹니다.MemberJpaRepositoryTest 에러2023-08-24 01:03:55.071 INFO 5528 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2023-08-24 01:03:55.325 WARN 5528 --- [ 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-08-24 01:03:56.092 INFO 5528 --- [ main] c.y.d.r.MemberJpaRepositoryTest : Started MemberJpaRepositoryTest in 4.755 seconds (JVM running for 6.003) 2023-08-24 01:03:56.216 INFO 5528 --- [ main] o.s.t.c.transaction.TransactionContext : Began transaction (1) for test context [DefaultTestContext@ec2cc4 testClass = MemberJpaRepositoryTest, testInstance = com.yy.datajpa.repository.MemberJpaRepositoryTest@68303c3e, testMethod = testMember@MemberJpaRepositoryTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@2a5b3fee testClass = MemberJpaRepositoryTest, locations = '{}', classes = '{class com.yy.datajpa.DataJpaApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@28194a50, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4149c063, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@62656be4, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@222a59e6, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@70e38ce1, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@77167fb7], 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@8dcacf1]; rollback [false] 2023-08-24 01:03:56.372 DEBUG 5528 --- [ main] org.hibernate.SQL : insert into member (member_id, age, team_id, username) values (default, ?, ?, ?) 2023-08-24 01:03:56.378 WARN 5528 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 42104, SQLState: 42S04 2023-08-24 01:03:56.378 ERROR 5528 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Table "MEMBER" not found (this database is empty); SQL statement: insert into member (member_id, age, team_id, username) values (default, ?, ?, ?) [42104-214] 2023-08-24 01:03:56.395 INFO 5528 --- [ main] p6spy : #1692806636395 | took 1ms | rollback | connection 2| url jdbc:h2:tcp://localhost/~/jpadata ; 2023-08-24 01:03:56.404 WARN 5528 --- [ main] o.s.test.context.TestContextManager : Caught exception while invoking 'afterTestMethod' callback on TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener@40dff0b7] for test method [public void com.yy.datajpa.repository.MemberJpaRepositoryTest.testMember()] and test instance [com.yy.datajpa.repository.MemberJpaRepositoryTest@68303c3e] org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:752) ~[spring-tx-5.3.29.jar:5.3.29] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) ~[spring-tx-5.3.29.jar:5.3.29] at org.springframework.test.context.transaction.TransactionContext.endTransaction(TransactionContext.java:131) ~[spring-test-5.3.29.jar:5.3.29] at org.springframework.test.context.transaction.TransactionalTestExecutionListener.afterTestMethod(TransactionalTestExecutionListener.java:255) ~[spring-test-5.3.29.jar:5.3.29] at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:445) ~[spring-test-5.3.29.jar:5.3.29] at org.springframework.test.context.junit.jupiter.SpringExtension.afterEach(SpringExtension.java:206) ~[spring-test-5.3.29.jar:5.3.29] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$12(TestMethodTestDescriptor.java:257) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:256) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:141) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) ~[junit5-rt.jar:na] at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) ~[junit-rt.jar:na] at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) ~[idea_rt.jar:na] at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) ~[junit-rt.jar:na] at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) ~[junit-rt.jar:na] at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) ~[junit-rt.jar:na] org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [insert into member (member_id, age, team_id, username) values (default, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:259) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at com.yy.datajpa.repository.MemberJpaRepository$$EnhancerBySpringCGLIB$$53401686.save(<generated>) at com.yy.datajpa.repository.MemberJpaRepositoryTest.testMember(MemberJpaRepositoryTest.java:25) 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:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Suppressed: org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:752) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) at org.springframework.test.context.transaction.TransactionContext.endTransaction(TransactionContext.java:131) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.afterTestMethod(TransactionalTestExecutionListener.java:255) at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:445) at org.springframework.test.context.junit.jupiter.SpringExtension.afterEach(SpringExtension.java:206) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$12(TestMethodTestDescriptor.java:257) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:256) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:141) ... 47 more Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:37) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:111) at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.prepare(GetGeneratedKeysDelegate.java:52) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3279) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3914) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:329) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:286) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:192) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:185) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:128) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:756) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:742) 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.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:315) at com.sun.proxy.$Proxy108.persist(Unknown Source) at com.yy.datajpa.repository.MemberJpaRepository.save(MemberJpaRepository.java:18) at com.yy.datajpa.repository.MemberJpaRepository$$FastClassBySpringCGLIB$$5644ac45.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ... 74 more Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MEMBER" not found (this database is empty); SQL statement: insert into member (member_id, age, team_id, username) values (default, ?, ?, ?) [42104-214] at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) at org.h2.message.DbException.get(DbException.java:223) at org.h2.message.DbException.get(DbException.java:199) at org.h2.command.Parser.getTableOrViewNotFoundDbException(Parser.java:8385) at org.h2.command.Parser.getTableOrViewNotFoundDbException(Parser.java:8369) at org.h2.command.Parser.readTableOrView(Parser.java:8358) at org.h2.command.Parser.readTableOrView(Parser.java:8328) at org.h2.command.Parser.parseInsert(Parser.java:1632) at org.h2.command.Parser.parsePrepared(Parser.java:814) at org.h2.command.Parser.parse(Parser.java:689) at org.h2.command.Parser.parse(Parser.java:661) at org.h2.command.Parser.prepareCommand(Parser.java:569) at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631) at org.h2.server.TcpServerThread.process(TcpServerThread.java:288) at org.h2.server.TcpServerThread.run(TcpServerThread.java:191) at java.base/java.lang.Thread.run(Thread.java:834) at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) at org.h2.engine.SessionRemote.readException(SessionRemote.java:637) at org.h2.engine.SessionRemote.done(SessionRemote.java:606) at org.h2.command.CommandRemote.prepare(CommandRemote.java:78) at org.h2.command.CommandRemote.<init>(CommandRemote.java:50) at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:480) at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116) at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:92) at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:1044) at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:344) at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java) at com.p6spy.engine.wrapper.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:133) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$2.doPrepare(StatementPreparerImpl.java:109) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) ... 107 more 2023-08-24 01:03:56.425 INFO 5528 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2023-08-24 01:03:56.428 INFO 5528 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2023-08-24 01:03:56.441 INFO 5528 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. Process finished with exit code -1 application.yml 파일spring: datasource: url: jdbc:h2:tcp://localhost/~/jpadata username: sa driver-class-name: org.h2.Driver jpa: defer-datasource-initialization: true hibernate: ddl-auto: create #애플리케이션 실행 시점에 테이블을 drop하고 다시 생성 properties: hibernate: # show_sql: true #System.out에 하이버네이트 실행 sql을 남김 format_sql: true logging: level: org.hibernate.SQL: debug #logger를 통해 하이버네이트 실행 SQL을 남김 # org.hibernate.type: trace entity - Member 코드package com.yy.datajpa.entity; import lombok.*; import javax.persistence.*; @Entity @Getter @Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) @ToString(of = {"id", "username", "age"}) public class Member { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "member_id") private Long id; private String username; private int age; public Member(String username) { this.username = username; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="team_id") private Team team; public Member(String username, int age){ this(username, age, null); } public Member(String username, int age, Team team){ this.username = username; this.age = age; if(team!= null){ changeTeam(team); } } public void changeTeam(Team team){ this.team = team; team.getMembers().add(this); } //jpa 표준 스펙에 entity에 기본적으로 기본생성자가 있어야 한다고 돼있음 //private으로 기본생성자 만들면 안됨. protected까지는 열어야함 //proxy 기술 같은 걸 쓸 때, 객체를 가져다 쓰므로 private으로 막아놓으면 이 때 막힐 수 있음. 그래서 최소 protected는 해둘 것. //annotation 으로 대체했음 // protected Member() { // // } } entity - Team 코드package com.yy.datajpa.entity; import lombok.*; import javax.persistence.*; import java.util.ArrayList; import java.util.List; @Entity @Getter @Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) @ToString(of = {"id", "name"}) public class Team { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "team_id") private Long id; private String name; public Team(String name) { this.name = name; } @OneToMany(mappedBy = "team") List<Member> members = new ArrayList<>(); } h2 데이터베이스 연결이 안되는 것 같은데 원인을 모르겠습니다 ㅠㅠh2 연결 전 화면도 아래에 첨부합니다. C:\Users\{사용자계정} 위치에는 아래와 같은 파일이 생성되어 h2 연결은 정상적으로 되는 상태입니다. 아무리 찾아봐도 원인을 찾지 못해 추가 실습을 이어나가지 못하고 있습니다.어떻게 하면 이 에러를 해결할 수 있나요 ㅠㅠ
-
미해결Practical Testing: 실용적인 테스트 가이드
Builder 패턴은 언제 사용하고 언제 사용하지 않는게 좋은 건가요
안녕하세요!! 강의 중 ApiResponse라는 제네릭 클래스를 만들 때에는 Builder를 사용하지 않으셨는데, 제네릭 클래스여서 사용하지 않은 건가요??그리고 혹시 Builder패턴을 사용을 하지 않았으면 하는 부분들이 있을까요?항상 친절하게 답해주셔서 감사합니다!!
-
해결됨Practical Testing: 실용적인 테스트 가이드
현업에서 TDD를 사용하시나요?
학습 관련 질문을 남겨주세요. 어떤 부분이 고민인지, 무엇이 문제인지 상세히 작성하면 더 좋아요!먼저 유사한 질문이 있었는지 검색해 보세요.서로 예의를 지키며 존중하는 문화를 만들어가요.강사님은 현업에서 TDD를 사용해서 개발하시는지 궁금합니다!
-
미해결스프링 DB 2편 - 데이터 접근 활용 기술
DB2 - 9.스프링 트랜잭션 이해 - 트랜잭션 적용 확인 강의 관련 질문
=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]트랜잭션이 실제 적용되고 있는지 확인하는 방법에서 TxApplyBasicTest 코드 짤때요 BasicService 프록시 객체가 스프링빈으로 자동등록되는데 왜 굳이 @TestConfiguration 에서 BasicService를 수동으로 빈 등록을 하는건가요?? 안해도 되는거 아닌가요?어차피 프록시 객체가 등록되어있어서 @Autowired로 의존관계 주입받을 수 있지 않나요??
-
미해결생산성을 향상시키는 스프링부트 기반의 API 템플릿 프로젝트 구현
XSS문의
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요! XSS관련하여서 JSON데이터를 암호화하는것을 수강하였습니다. 이 데이터를 react로 보낸다고 하면 react는 이를 어떻게 decode하나요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
엔티티 그래프를 사용하지 않는 이유가 있나요?
연관 데이터를 불러와야 하는 상황에서 지연 로딩 전략을 취하고 페치조인을 사용하는 것이 N+1 문제를 해결하는 방법이자, 성능 최적화의 방법이라고 알고 있습니다. 그런데 JPA에서 엔티티 그래프를 사용해도 N+1 문제를 해결할 수 있지 않나요? 사용 방법도 더 편리하고 좋은 것 같은데, 엔티티 그래프를 사용하지 않는 이유가 있나요?
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
property name="hibernate.hbm2ddl.auto" value="create" 문제인가요?
섹션 9 값 타입 부분의 값 타입과 불변 객체 실습을 진행하고 있는데 계속 다음과 같은 에러가 떠서 아래와 같이 첨부합니다 8월 23, 2023 5:18:29 오후 org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformationINFO: HHH000204: Processing PersistenceUnitInfo [ name: hello ...]8월 23, 2023 5:18:29 오후 org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {5.3.10.Final}8월 23, 2023 5:18:29 오후 org.hibernate.cfg.Environment <clinit>INFO: HHH000206: hibernate.properties not found8월 23, 2023 5:18:30 오후 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>INFO: HCANN000001: Hibernate Commons Annotations {5.0.4.Final}8월 23, 2023 5:18:33 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureWARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)8월 23, 2023 5:18:33 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreatorINFO: HHH10001005: using driver [org.h2.Driver] at URL [jdbc:h2:tcp://localhost/~/test]8월 23, 2023 5:18:33 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreatorINFO: HHH10001001: Connection properties: {user=sa}8월 23, 2023 5:18:33 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreatorINFO: HHH10001003: Autocommit mode: false8월 23, 2023 5:18:33 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>INFO: HHH000115: Hibernate connection pool size: 20 (min=1)8월 23, 2023 5:18:33 오후 org.hibernate.dialect.Dialect <init>INFO: HHH000400: Using dialect: org.hibernate.dialect.H2DialectHibernate: drop table Child if existsHibernate: drop table Item if existsHibernate: drop table Member if exists8월 23, 2023 5:18:35 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnectionINFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@5db6b845] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptionWARN: GenerationTarget encountered exception accepting command : Error executing DDL " drop table Member if exists" via JDBC Statementorg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " drop table Member if exists" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359) at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241) at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at hellojpa.JpaMain.main(JpaMain.java:15)Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "MEMBER" because "FKJNJ8UNGT7V35Y6LFXUXCRJBBR" depends on it; SQL statement: drop table Member if exists [90107-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:98) at org.h2.command.ddl.DropTable.update(DropTable.java:124) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.base/java.lang.Thread.run(Thread.java:833) at org.h2.message.DbException.getJdbcSQLException(DbException.java:573) at org.h2.engine.SessionRemote.done(SessionRemote.java:607) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 more8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptionWARN: GenerationTarget encountered exception accepting command : Error executing DDL " drop table Team if exists" via JDBC Statementorg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " drop table Team if exists" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359) at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241) at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at hellojpa.JpaMain.main(JpaMain.java:15)Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "TEAM" because "FKL7WSNY760HJY6X19KQNDUASBM" depends on it; SQL statement: drop table Team if exists [90107-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:98) at org.h2.command.ddl.DropTable.update(DropTable.java:124) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.base/java.lang.Thread.run(Thread.java:833) at org.h2.message.DbException.getJdbcSQLException(DbException.java:573) at org.h2.engine.SessionRemote.done(SessionRemote.java:607) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 moreHibernate: drop table MemberProduct if existsHibernate: drop table Parent if existsHibernate: drop table Product if existsHibernate: drop table Team if existsHibernate: drop sequence if exists hibernate_sequenceHibernate: create sequence hibernate_sequence start with 1 increment by 1Hibernate: create table Child ( id bigint not null, name varchar(255), parent_id bigint, primary key (id) )Hibernate: create table Item ( DTYPE varchar(31) not null, id bigint not null, name varchar(255), price integer not null, artist varchar(255), author varchar(255), isbn varchar(255), actor varchar(255), director varchar(255), primary key (id) )Hibernate: create table Member ( MEMBER_ID bigint not null, city varchar(255), street varchar(255), ZIPCODE varchar(255), USERNAME varchar(255), endDate timestamp, startDate timestamp, TEAM_ID bigint, primary key (MEMBER_ID) )Hibernate: create table MemberProduct ( id bigint not null, count integer not null, orderDateTime timestamp, price integer not null, MEMBER_ID bigint, PRODUCT_ID bigint, primary key (id) )Hibernate: create table Parent ( id bigint not null, name varchar(255), primary key (id) )8월 23, 2023 5:18:35 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnectionINFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@29a98d9f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptionWARN: GenerationTarget encountered exception accepting command : Error executing DDL " create table Member ( MEMBER_ID bigint not null, city varchar(255), street varchar(255), ZIPCODE varchar(255), USERNAME varchar(255), endDate timestamp, startDate timestamp, TEAM_ID bigint, primary key (MEMBER_ID) )" via JDBC Statementorg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " create table Member ( MEMBER_ID bigint not null, city varchar(255), street varchar(255), ZIPCODE varchar(255), USERNAME varchar(255), endDate timestamp, startDate timestamp, TEAM_ID bigint, primary key (MEMBER_ID) )" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at hellojpa.JpaMain.main(JpaMain.java:15)Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MEMBER" already exists; SQL statement: create table Member ( MEMBER_ID bigint not null, city varchar(255), street varchar(255), ZIPCODE varchar(255), USERNAME varchar(255), endDate timestamp, startDate timestamp, TEAM_ID bigint, primary key (MEMBER_ID) ) [42101-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.command.ddl.CreateTable.update(CreateTable.java:89) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.base/java.lang.Thread.run(Thread.java:833) at org.h2.message.DbException.getJdbcSQLException(DbException.java:451) at org.h2.engine.SessionRemote.done(SessionRemote.java:607) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 more8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptionWARN: GenerationTarget encountered exception accepting command : Error executing DDL " create table Team ( TEAM_ID bigint not null, INSERT_MEMBER varchar(255), createdDate timestamp, UPDATE_MEMBER varchar(255), lastModifiedDate timestamp, name varchar(255), primary key (TEAM_ID) )" via JDBC Statementorg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " create table Team ( TEAM_ID bigint not null, INSERT_MEMBER varchar(255), createdDate timestamp, UPDATE_MEMBER varchar(255), lastModifiedDate timestamp, name varchar(255), primary key (TEAM_ID) )" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at hellojpa.JpaMain.main(JpaMain.java:15)Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "TEAM" already exists; SQL statement: create table Team ( TEAM_ID bigint not null, INSERT_MEMBER varchar(255), createdDate timestamp, UPDATE_MEMBER varchar(255), lastModifiedDate timestamp, name varchar(255), primary key (TEAM_ID) ) [42101-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.command.ddl.CreateTable.update(CreateTable.java:89) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.base/java.lang.Thread.run(Thread.java:833) at org.h2.message.DbException.getJdbcSQLException(DbException.java:451) at org.h2.engine.SessionRemote.done(SessionRemote.java:607) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 moreHibernate: create table Product ( id bigint not null, name varchar(255), primary key (id) )Hibernate: create table Team ( TEAM_ID bigint not null, INSERT_MEMBER varchar(255), createdDate timestamp, UPDATE_MEMBER varchar(255), lastModifiedDate timestamp, name varchar(255), primary key (TEAM_ID) )Hibernate: alter table Child add constraint FKlh67j1n7x7gt59u0pbkwqh6o6 foreign key (parent_id) references ParentHibernate: alter table Member add constraint FKl7wsny760hjy6x19kqnduasbm foreign key (TEAM_ID) references TeamHibernate: alter table MemberProduct add constraint FKjnj8ungt7v35y6lfxuxcrjbbr foreign key (MEMBER_ID) references MemberHibernate: alter table MemberProduct add constraint FKrgt6jorh7iaec1tae84ljye8c foreign key (PRODUCT_ID) references Product8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptionWARN: GenerationTarget encountered exception accepting command : Error executing DDL " alter table Member add constraint FKl7wsny760hjy6x19kqnduasbm foreign key (TEAM_ID) references Team" via JDBC Statementorg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " alter table Member add constraint FKl7wsny760hjy6x19kqnduasbm foreign key (TEAM_ID) references Team" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:375) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at hellojpa.JpaMain.main(JpaMain.java:15)Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Constraint "FKL7WSNY760HJY6X19KQNDUASBM" already exists; SQL statement: alter table Member add constraint FKl7wsny760hjy6x19kqnduasbm foreign key (TEAM_ID) references Team [90045-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:114) at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:78) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.base/java.lang.Thread.run(Thread.java:833) at org.h2.message.DbException.getJdbcSQLException(DbException.java:573) at org.h2.engine.SessionRemote.done(SessionRemote.java:607) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 more8월 23, 2023 5:18:35 오후 org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSourcesINFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@45cec376'Hibernate: call next value for hibernate_sequenceHibernate: call next value for hibernate_sequenceHibernate: /* insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?)Hibernate: /* insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?)8월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl releaseINFO: HHH000010: On release of batch it still contained JDBC statements8월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.batch.internal.BatchingBatch performExecutionERROR: HHH000315: Exception executing batch [org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.MEMBER(MEMBER_ID) [2, 'newCity', 'street', '10000', 'member2', NULL, NULL, NULL]"; SQL statement:/* insert hellojpa.Member / insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?) [23505-199]], SQL: / insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?)8월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptionsWARN: SQL Error: 23505, SQLState: 235058월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptionsERROR: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.MEMBER(MEMBER_ID) [2, 'newCity', 'street', '10000', 'member2', NULL, NULL, NULL]"; SQL statement:/* insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?) [23505-199]8월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptionsERROR: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.MEMBER(MEMBER_ID) [1, 'newCity', 'street', '10000', 'member1', NULL, NULL, NULL]"; SQL statement:/* insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?) [23505-199]8월 23, 2023 5:18:36 오후 org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailureERROR: HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute batch]javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:81) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:107) at hellojpa.JpaMain.main(JpaMain.java:39)Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute batch at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:65) ... 2 moreCaused by: org.hibernate.exception.ConstraintViolationException: could not execute batch at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:129) at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:105) at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:147) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.executeBatch(JdbcCoordinatorImpl.java:212) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:633) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:511) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3290) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2486) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104) ... 1 moreCaused by: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.MEMBER(MEMBER_ID) [2, 'newCity', 'street', '10000', 'member2', NULL, NULL, NULL]"; SQL statement:/* insert hellojpa.Member */ insert into Member (city, street, ZIPCODE, USERNAME, endDate, startDate, MEMBER_ID) values (?, ?, ?, ?, ?, ?, ?) [23505-199] at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1298) at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:119) ... 17 more8월 23, 2023 5:18:36 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stopINFO: HHH10001008: Cleaning up connection pool [jdbc:h2:tcp://localhost/~/test]Process finished with exit code 0 참고로 이전에 create-drop을 사용해 테이블을 삭제했습니다.
-
미해결스프링 DB 2편 - 데이터 접근 활용 기술
@Slf4j
@Slf4j 롬복을 이용하여 log값을 출력할때,맨 위 클래스에 작성하고 사용하지 않고 클래스 위에 각각 @Slf4j를 작성하는 이유는 무엇인지 궁금합니다.
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
delivery id 쪽에 에러가 뜨는 것 같은데 원인을 모르겠어요
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. 에러메시지가 다음과 같습니다.2023-08-23 16:17:14.544 ERROR 6412 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: component: jpabook.jpashop.domain.Delivery property not found: id delivery랑 member쪽에 문제가 있는 것 같은데 원인을 모르겠네요...
-
해결됨자바 ORM 표준 JPA 프로그래밍 - 기본편
예상치 못한 쿼리문이 나갑니다.
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]코드@Entity public class Member { @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "member_id") private Long id; @ManyToOne @JoinColumn(name = "team_id") private Team team; // getter & setter }@Entity public class Team { @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "team_id") private Long id; private String name; @OneToMany(mappedBy = "team") private List<Member> members; // getter & setter }public class Main { public static void main(String[] args) { try { tx.begin(); Team team = new Team(); team.setName("teamA"); em.persist(team); Member member = new Member(); member.setTeam(team); em.persist(member); em.flush(); em.clear(); System.out.println("1"); Member findMember = em.find(Member.class, member.id()); System.out.println("2"); Team membersTeam = findMember.team(); System.out.println("3"); List<Member> members = membersTeam.members(); System.out.println("4"); System.out.println("size = " + members.size()); // 이때 예상치 못한 select 문이 나가는 것으로 의심된다. 출력 결과는 1 tx.commit(); System.out.println("5"); } catch (Exception e) { // handle Exception } finally { // close EntityManager } } }양뱡향 연관관계 강의를 들으며 위와 같은 코드를 작성해보았습니다.실행 결과질문4번과 5번 사이에 아무런 쿼리문이 나가지 않는 것을 기대했습니다. 하지만 왜인지 Member 테이블에서 Team의 아이디로 Member를 조회하는 쿼리문이 나갑니다.제가 생각했을 땐 members.size()를 호출함으로써 나가는 것 같은데, 위 코드는 단순히 List 형 객체의 size를 List<Member> members 는 단순히 자바에서 List 형 객체 아닌가요? 이때 왜 조회 쿼리가 나가는지 잘 모르겠습니다.만약, 나가더라도 Member 테이블에서 membersTeam: Team 의 아이디로 count 쿼리가 나가야 정상적일 것 같습니다.어느 부분을 놓쳤을까요?
-
미해결스프링 DB 2편 - 데이터 접근 활용 기술
TxBasicTest
TxBasicTest에서proxyCheck에서 테스트를 돌리면 에러가 나옵니다기대값은 true인데 false가 나온다고합니다. package hello.springtx.apply; import lombok.extern.slf4j.Slf4j; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.transaction.support.TransactionSynchronizationManager; import static org.assertj.core.api.Assertions.assertThat; @Slf4j @SpringBootTest public class TxBasicTest { @Autowired BasicService basicService; @Test void proxyCheck(){ log.info("aop class={}", basicService.getClass()); assertThat(AopUtils.isAopProxy(basicService)).isTrue(); } @TestConfiguration static class TxApplyBasicConfig{ @Bean BasicService basicService(){ return new BasicService(); } } @Slf4j static class BasicService{ public void tx(){ log.info("call tx"); boolean txActive = TransactionSynchronizationManager.isActualTransactionActive(); log.info("tx active={}", txActive); } public void nonTx(){ log.info("call nonTx"); boolean txActive = TransactionSynchronizationManager.isActualTransactionActive(); log.info("nonTx active={}", txActive); } } }
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
SOA vs MSA
구분에 대해 명확히 이해가 되지 않는데요,SOA 경우도 서비스 단위 개발이고 Microservice도 그렇지 않나요? 그 규모의 차이가 둘을 구분 짓는 건가요?ex) SOA의 서비스 단위가 숙박 예약 기능이라고 하면Microservice는 숙박조회, 결제 ... 으로 더 세분화 그리고 SOA에서 직접 서비스간에 데이터 교환을 하는 것에서 발생하는 의존 문제로 인해 ESB를 도입했다고 봤는데요, Microservice에서는 API를 통해 서비스 간 통신 시 이런 의존문제가 없을 수 있는건가요? 뭔가 구체적인 예시로 비교해주시면 감사하겠습니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
eureka에서 클라이언트 삭제
구동시킨 클라이언트를 모두 중지하였는데 유레카에서 삭제가 안되네요.. 캐시가 남는걸까요?