fastcampus-eatgo icon indicating copy to clipboard operation
fastcampus-eatgo copied to clipboard

34강 실습중 @GeneratedValue가 이상하게 작동하는 것 같아서 질문드립니다!

Open oh980225 opened this issue 4 years ago • 3 comments

원래 Id값이 1씩 증가해야하는데 갑자기 1씩 증가하다가도 30씩 증가하고 그럽니다... 구글링해도 정확한 이유를 모르겠어서 질문드립니다! 혹시 해결방법과 이유를 아신다면 답변 부탁드립니다!!

oh980225 avatar Apr 20 '20 15:04 oh980225

저도 그러네요 1 2 33 34 이런식으로 30으로 증가합니다. 수정하려고 해봤는데 잘안되네요..

ahnseongeun avatar May 06 '20 15:05 ahnseongeun

그쵸...ㅇ.ㅇ 저는 일단 그래서 그 통합적으로 value가 오르는게 아닌 각 요소별로 id가 증가하는 설정이 있길래 나중에 그걸로 고쳐서 확인해보려구요.

2020년 5월 7일 (목) 오전 12:03, ahnseongeun [email protected]님이 작성:

저도 그러네요 1 2 33 34 이런식으로 30으로 증가합니다. 수정하려고 해봤는데 잘안되네요..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ahastudio/fastcampus-eatgo/issues/41#issuecomment-624703514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICKLL3WQJ44DKQCNG5K2ULRQF35VANCNFSM4MMRWLHQ .

oh980225 avatar May 06 '20 16:05 oh980225

여러 Entity를 사용하고 있다면 1씩 증가하지 않는 게 정상입니다. 강의에선 JPA를 깊이 다루지 않는데, GeneratedValue의 네 가지 전략을 확인해 보시면 도움이 될 겁니다. 만약 기존에 DB를 다룬 경험이 있고, Primary Key를 그대로 사용하는 환경에 익숙하시다면 IDENTITY 전략을 선택하세요.

https://www.objectdb.com/java/jpa/entity/generated

ahastudio avatar Sep 27 '20 16:09 ahastudio