게시글
질문&답변
2021.12.01
test code 실행 시, IllegalStateException: unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test 에러 발생합니다.
(사진) 위와 같이 설정완료 되어있습니다. 크롬 or 엣지에서 ctrl + shift + n을 눌러 시크릿 모드로 진입 후 해당 링크를 입력하여 아래와 같은 페이지가 출력되는지 확인까지 완료 했습니다.
- 0
- 3
- 357
질문&답변
2021.10.12
값타입 컬렉션을 엔티티로 변경 후에...
로그가 첨부가 안되서 여기에 첨부합니다. 17:24:03.204 [main] DEBUG org.hibernate.SQL - /* insert collection row jpabasic.hellojpa.Member.favoriteFoods */ insert into FAVORITE_FOOD (MEMBER_ID, FOOD_NAME) values (?, ?) 17:24:03.204 [main] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - Done inserting collection: 3 rows inserted ===============START==================== 17:24:03.207 [main] DEBUG org.hibernate.SQL - select member0_.MEMBER_ID as member_i1_5_0_, member0_.city as city2_5_0_, member0_.street as street3_5_0_, member0_.zipcode as zipcode4_5_0_, member0_.team_id as team_id5_5_0_, member0_.name as name6_5_0_, member0_.edDate as eddate7_5_0_, member0_.stDate as stdate8_5_0_ from Member member0_ where member0_.MEMBER_ID=? 17:24:03.207 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl - On call to EntityIdentifierReaderImpl#resolve, EntityKey was already known; should only happen on root returns with an optional identifier specified 17:24:03.209 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Resolving attributes for [jpabasic.hellojpa.Member#1] 17:24:03.209 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `addressHistory` : value = NOT NULL COLLECTION 17:24:03.209 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`addressHistory`) - enhanced for lazy-loading? - false 17:24:03.211 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `favoriteFoods` : value = NOT NULL COLLECTION 17:24:03.211 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`favoriteFoods`) - enhanced for lazy-loading? - false 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `homeAddress` : value = [Ljava.lang.Object;@3ebe4ccc 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`homeAddress`) - enhanced for lazy-loading? - false 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `team_id` : value = null 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`team_id`) - enhanced for lazy-loading? - false 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `username` : value = 서울역 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`username`) - enhanced for lazy-loading? - false 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Processing attribute `workPeriod` : value = null 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Attribute (`workPeriod`) - enhanced for lazy-loading? - false 17:24:03.212 [main] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Done materializing entity [jpabasic.hellojpa.Member#1] 17:24:03.212 [main] DEBUG org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader - Done entity load : jpabasic.hellojpa.Member#1 17:24:03.216 [main] DEBUG org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer - Loading collection: [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.216 [main] DEBUG org.hibernate.SQL - select favoritefo0_.MEMBER_ID as member_i1_3_0_, favoritefo0_.FOOD_NAME as food_nam2_3_0_ from FAVORITE_FOOD favoritefo0_ where favoritefo0_.MEMBER_ID=? 17:24:03.218 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl - Preparing collection initializer : [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.223 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl - Found row of collection: [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.223 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl - Found row of collection: [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.223 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl - Found row of collection: [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.223 [main] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext - 1 collections were found in result set for role: jpabasic.hellojpa.Member.favoriteFoods 17:24:03.224 [main] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext - Collection fully initialized: [jpabasic.hellojpa.Member.favoriteFoods#1] 17:24:03.224 [main] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext - 1 collections initialized for role: jpabasic.hellojpa.Member.favoriteFoods 17:24:03.224 [main] DEBUG org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer - Done loading collection ===============ENTITY==================== 17:24:03.224 [main] DEBUG org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer - Loading collection: [jpabasic.hellojpa.Member.addressHistory#1] 17:24:03.224 [main] DEBUG org.hibernate.SQL - select addresshis0_.MEMBER_ID as member_i5_0_0_, addresshis0_.id as id1_0_0_, addresshis0_.id as id1_0_1_, addresshis0_.city as city2_0_1_, addresshis0_.street as street3_0_1_, addresshis0_.zipcode as zipcode4_0_1_ from ADDRESS addresshis0_ where addresshis0_.MEMBER_ID=? 17:24:03.226 [main] DEBUG org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl - Preparing collection initializer : [jpabasic.hellojpa.Member.addressHistory#1] 17:24:03.226 [main] DEBUG org.hibernate.engine.transaction.internal.TransactionImpl - rolling back 17:24:03.229 [main] DEBUG org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl - Initiating JDBC connection release from afterTransaction 17:24:03.229 [main] DEBUG org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl - Initiating JDBC connection release from afterTransaction 17:24:03.229 [main] WARN org.hibernate.engine.loading.internal.LoadContexts - HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@4ee25d80 17:24:03.230 [main] WARN org.hibernate.engine.loading.internal.CollectionLoadContext - HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries 17:24:03.230 [main] DEBUG org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl - HHH000420: Closing un-released batch 17:24:03.230 [main] DEBUG org.hibernate.internal.SessionFactoryImpl - HHH000031: Closing 17:24:03.231 [main] DEBUG org.hibernate.type.spi.TypeConfiguration$Scope - Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@16a35bd] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@5eccd3b9] 17:24:03.232 [main] DEBUG org.hibernate.service.internal.AbstractServiceRegistryImpl - Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries 17:24:03.232 [main] INFO org.hibernate.orm.connections.pooling - HHH10001008: Cleaning up connection pool [jdbc:h2:tcp://localhost/~/hellojpa] 17:24:03.234 [main] DEBUG org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl - Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries Process finished with exit code 0
- 0
- 4
- 1.2K
질문&답변
2021.10.12
값타입 컬렉션을 엔티티로 변경 후에...
try { Movie movie = new Movie(); movie.setDirector("장항선"); movie.setActor("황정민"); movie.setName("킹덤"); movie.setPrice(10000); em.persist(movie); em.flush(); em.clear(); Movie findmv = em.find(Movie.class, movie.getId()); System.out.println("find Movie = " + findmv.getName()); Member member = new Member(); member.setUsername("서울역"); member.setHomeAddress(new Address("서울", "서울로", "123-456")); member.getFavoriteFoods().add("chicken"); member.getFavoriteFoods().add("pizza"); member.getFavoriteFoods().add("ddukbbokkki"); member.getAddressHistory().add(new AddressEntity("구미", "도량동", "123456")); member.getAddressHistory().add(new AddressEntity("포항", "두호동", "999888")); em.persist(member); em.flush(); em.clear(); System.out.println("===============START===================="); Member findmember = em.find(Member.class, member.getId()); findmember.setUsername("서초맨"); Address newAddress = new Address("서초구", "THE H APT", "688987"); findmember.setHomeAddress(newAddress); //chicken --> black noodle findmember.getFavoriteFoods().remove("chicken"); findmember.getFavoriteFoods().add("black noodle"); //도량동 --> 봉곡동 // 값타임 컬렉션 일 경우에 값을 변경하는 방법 : 비추. //findmember.getAddressHistory().remove(new AddressEntity(new Address("구미", "도량동", "123456"))); //findmember.getAddressHistory().add(new AddressEntity(new Address("구미", "봉곡동", "654321"))); System.out.println("===============ENTITY===================="); // 값타입을 래핑한 엔티티 타입일 경우, 값을 변경하는 방법 // // findmember.getAddressHistory().remove(0); findmember.getAddressHistory().get(0).getAddress().setCity("봉곡동"); //findmember.getAddressHistory().add(new AddressEntity(new Address("구미", "봉곡동", "654321"))); tx.commit();} catch (Exception e) { tx.rollback();} finally { em.close();} 위와 같이 했을 때, 저는 결과가 반영이 되지 않습니다.로그를 봐도 어데이트 쿼리도 나가지 않습니다.아래는 로그입니다.
- 0
- 4
- 1.2K
질문&답변
2021.10.10
값타입 컬렉션을 엔티티로 변경 후에...
System.out.println("===============START===================="); Member findmember = em.find(Member.class, member.getId()); findmember.setUsername("서초맨"); Address newAddress = new Address("서초구", "THE H APT", "688987"); findmember.setHomeAddress(newAddress); //chicken --> black noodle findmember.getFavoriteFoods().remove("chicken"); findmember.getFavoriteFoods().add("black noodle"); //도량동 --> 봉곡동 // 값타임 컬렉션 일 경우에 값을 변경하는 방법 : 비추. //findmember.getAddressHistory().remove(new AddressEntity(new Address("구미", "도량동", "123456"))); //findmember.getAddressHistory().add(new AddressEntity(new Address("구미", "봉곡동", "654321"))); System.out.println("===============ENTITY===================="); // 값타입을 래핑한 엔티티 타입일 경우, 값을 변경하는 방법 ==>> 이 부분이 해결이 부분입니다. // findmember.getAddressHistory().remove(0); findmember.getAddressHistory().add(new AddressEntity(new Address("구미", "봉곡동", "654321"))); tx.commit();
- 0
- 4
- 1.2K