Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

회원 관련 엔티티 추가 (그리고 H2 환경 추가) #8

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

greenn-lab
Copy link

정상적으로 테이블이 생성되는지 확인해보려고 일단 H2 설정 넣었어요.

  • build.gradle
  • application.yml

회원 관련 엔티티 생성하였습니다.

  • Member.java
  • CommonMember.java
  • AdminMember.java
  • Address.java
  • LoginHistory

그리고, boolean 타입을 대응하는 Converter 생성했어요.

  • BooleanToYOrNConverter.java

public class BooleanToYOrNConverter implements AttributeConverter<Boolean, String> {
@Override
public String convertToDatabaseColumn(Boolean attribute) {
return attribute ? "Y" : "N";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttributeConverter 라니..! 새로운걸 배워갑니다!

그런데 만약 Boolean attributenull 이면 조건식이 어떻게 되는건가요?
별도의 NPE 체크 없이 사용 가능한가요??

Copy link
Author

@greenn-lab greenn-lab May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

당연히 안되겠죠^^;
좋은 지적 감사합니다, 수정할게요. 항상 대충하는 버릇이...

코드 리뷰 하니까 좋네요, 성준님😍


@Override
public Boolean convertToEntityAttribute(String dbData) {
return dbData.equals("Y");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 dbData 값이 null 이면 NPE 가 발생할 것 같습니다..!
"Y".equals(dbData); 로 해 보시는 것은 어떨까요?
(또는 StringUtils 등을 적극 활용해보는 것도 좋을 것 같습니다!!)

요즘 NPE 로 고생중이라 JPA 외적인 부분들만 눈에 들어오네요 ㅠㅠ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최근에 저도 실무에 코딩 가이드 적용하면서 NPE 지적을 엄청 받았으면서 또 이랬어요.
수정할게요~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants