• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

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

20.11.28 13:23 작성 조회수 199

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

;

답변 3

·

답변을 작성해보세요.

2

안녕하세요. Youngsoo, Na님

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

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

그럼 답변 남겨주세요^^

1

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

0

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