inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

상품 등록

멤버는 DB에 잘 들어가는데 아이템은 안 들어가네요..

444

Youngsoo, Na

작성한 질문수 4

0

로그를 보니까 멤버는 insert 문이 실행되서 잘 들어가는데, item의 경우에는 insert 문이 실행되지 않습니다. 화면 이동도 되고

itemService.saveItem(book);  이 실행되서

em.persist(item) 까지 실행되는걸 콘솔로 확인 했는데

DB에 들어가지 않을 경우 엔티티 설계가 잘 못된 것인가요?

왜 에러가 나지 않고 실행이 되어버릴까요?

2020-11-28 13:17:08.419  INFO 13360 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]

2020-11-28 13:17:08.423 TRACE 13360 --- [         task-1] o.h.type.spi.TypeConfiguration$Scope     : Handling #sessionFactoryCreated from [org.hibernate.internal.SessionFactoryImpl@66b0a445] for TypeConfiguration

2020-11-28 13:17:08.424  INFO 13360 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'

2020-11-28 13:17:13.552  INFO 13360 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'

2020-11-28 13:17:13.552  INFO 13360 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'

2020-11-28 13:17:13.558  INFO 13360 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Completed initialization in 6 ms

2020-11-28 13:17:20.260 DEBUG 13360 --- [nio-8080-exec-6] org.hibernate.SQL                        : 

    call next value for hibernate_sequence

2020-11-28 13:17:20.264  INFO 13360 --- [nio-8080-exec-6] p6spy                                    : #1606537040264 | took 1ms | statement | connection 4| url jdbc:h2:tcp://localhost/~/jpashop

call next value for hibernate_sequence

call next value for hibernate_sequence;

2020-11-28 13:17:20.280  INFO 13360 --- [nio-8080-exec-6] p6spy                                    : #1606537040280 | took 0ms | commit | connection 4| url jdbc:h2:tcp://localhost/~/jpashop

;

2020-11-28 13:17:20.341 DEBUG 13360 --- [nio-8080-exec-7] org.hibernate.SQL                        : 

    select

        item0_.item_id as item_id2_3_,

        item0_.name as name3_3_,

        item0_.price as price4_3_,

        item0_.stock_quantity as stock_qu5_3_,

        item0_.artist as artist6_3_,

        item0_.etc as etc7_3_,

        item0_.author as author8_3_,

        item0_.isbn as isbn9_3_,

        item0_.actor as actor10_3_,

        item0_.director as directo11_3_,

        item0_.dtype as dtype1_3_ 

    from

        item item0_

2020-11-28 13:17:20.342  INFO 13360 --- [nio-8080-exec-7] p6spy                                    : #1606537040342 | took 0ms | statement | connection 5| url jdbc:h2:tcp://localhost/~/jpashop

select item0_.item_id as item_id2_3_, item0_.name as name3_3_, item0_.price as price4_3_, item0_.stock_quantity as stock_qu5_3_, item0_.artist as artist6_3_, item0_.etc as etc7_3_, item0_.author as author8_3_, item0_.isbn as isbn9_3_, item0_.actor as actor10_3_, item0_.director as directo11_3_, item0_.dtype as dtype1_3_ from item item0_

select item0_.item_id as item_id2_3_, item0_.name as name3_3_, item0_.price as price4_3_, item0_.stock_quantity as stock_qu5_3_, item0_.artist as artist6_3_, item0_.etc as etc7_3_, item0_.author as author8_3_, item0_.isbn as isbn9_3_, item0_.actor as actor10_3_, item0_.director as directo11_3_, item0_.dtype as dtype1_3_ from item item0_;

2020-11-28 13:17:20.344  INFO 13360 --- [nio-8080-exec-7] p6spy                                    : #1606537040344 | took 0ms | commit | connection 5| url jdbc:h2:tcp://localhost/~/jpashop

;

웹앱 spring spring-boot JPA java

답변 3

2

김영한

안녕하세요. Youngsoo, Na님

혹시 ItemService에서 @Transactional이 잘 달려있는지 확인해봐주세요.

@Transactional(readOnly=true)만 달려 있으면 저장이 안됩니다.

그럼 답변 남겨주세요^^

1

Youngsoo, Na

빠른 답변 감사드립니다. 이렇게 빨리 남겨주실 줄이야 이제야 확인했네요 ㅠㅠ 저에게 슬픈 소식이 있습니다.. 컴퓨터가 맛이가서 오늘 다시 포맷했습니다... 소스코드가 다 날라가서, 다시 자바부터 설치해서 처음부터 해야 할거 같습니다. 다시 할 때는 @Transactional 이 잘 달려있는지 확인해보겠습니다.

0

김영한

아이쿠! 이런 슬픈 소식이, 복습해서 더 많이 배우시겠네요^^ 화이팅!

sdk 설정 오류

0

48

2

오탈자 - @Transactional

0

53

1

src/test/resources 테스트 경로 문제

0

49

1

상품 등록후 H2 db 출력 순서 바꿀 수 있나요?

0

62

1

MemberRepositoryTest 실행오류

0

77

1

boot 4.x >>> trasasction rolled back log & p6spy(영한님, 수업 자료 업데이트 해주시면 감사하겠습니다!!)

1

183

2

강의 마지막 QueryDSL 사용 부분 질문있습니다

1

137

2

클라이언트에서 isbn과 author 수정 요청을 한 경우에 대해 질문드립니다.

0

50

1

도메인 모델 패턴 vs 트랜잭션 스크립트 패턴

0

71

1

기본 생성자

0

59

1

h2 DB 연결시 jdbc url 변경 이유가 궁금합니다.

0

100

1

멤버서비스테스트 부분에서 막힙니다.

0

163

4

실무에서도 EntityManager를 이용해서 많이 작업하는 편일까요?

0

115

1

초반에 h2 다운로드 과정 꼭 필요한가요?

0

117

2

자신 필드에도 get으로 접근하는 이유가 있을까요?

0

111

1

24분 27초 연관관계 편의 메서드 위치

0

112

1

단건 주문만 가능하게 한건 의도한 부분이신가요?

0

107

2

빌드 툴, Gradle

0

57

1

h2연결은 된 것 같은데 엔티티 테이블까지 작성 후 확인해보아도 테이블이 안보입니다

0

73

2

Repository에서 EntityManager 주입 방식 차이

0

87

1

롬복과 사용자 정의 setter 메서드

0

70

1

주문 목록 조회 fetch join 질문드립니다

0

80

1

dirty checking 질문드립니다.

0

80

1

동시성 관련 질문입니다

0

72

1