Skip to content

설만수 1주차 과제 #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tjfakstn
Copy link

롤토체스 데이터베이스

챔피언 정보(Id, 이름, 코스트)
스크린샷 2024-09-30 오후 11 06 02

시너지 정보(Id, 이름, 최대 시너지 활성 수)
스크린샷 2024-09-30 오후 11 07 48

챔피언과 시너지를 매핑한 테이블
스크린샷 2024-09-30 오후 11 08 19
(위 테이블도 코드로 작성해보려 했는데 모르는게 너무 많아서 나중에 더 찾아보고 하겠습니다.)

Comment on lines +15 to +16
@Column(name = "Id_champion")
private Long id;
Copy link
Member

Choose a reason for hiding this comment

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

익숙한 주제로 작성하는 것 매우 좋습니다ㅎㅎㅎ
틀린 것은 아니지만! 관례 상 자주 사용되는 패턴이 있습니다.
MySQL에서는 Column 이름을 snake_case로 작성하는 것이 일반적입니다. 참고!
그리고 table명_id 구조로 PK를 작성하는 편이기도 합니다.
따라서 아래처럼 써보시는 것이 어떠할까 싶네용

Suggested change
@Column(name = "Id_champion")
private Long id;
@Column(name = "champion_id")
private Long id;


private String name;

private Integer max_activate;
Copy link
Member

Choose a reason for hiding this comment

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

디테일하게 필드 명 적어주신 부분 좋습니다!
다만 자바에서는 이러한 필드명은 대부분 CamelCase로 작성하는 것을 권장하고 있습니다.
이렇게 CamelCase로 작성한 필드들에 대해서는 jpa를 통해 MySQL로 전달될 때 snake_case로 자동으로 변경됩니다.
ex) JAVA : maxActivate -> JPA -> MySQL : max_activate

따라서 아래처럼 작성하는 것이 보편적이니 참고하시면 될 것 같아요.

Suggested change
private Integer max_activate;
private Integer maxActivate

Comment on lines +34 to +42
Champion championTest = championRepository.findByCost(2);
Champion championTest2 = championRepository.findByName("헤카림");
Champion championTest3 = championRepository.findByNameAndCost("누누", 2);
Champion championTest4 = championRepository.findByCost(5);

Assertions.assertThat(championTest).isNull();
Assertions.assertThat(championTest2).isNull();
Assertions.assertThat(championTest3).isNull();
Assertions.assertThat(championTest4).isNotNull();
Copy link
Member

Choose a reason for hiding this comment

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

꼼꼼하게 assertThat 작성해주신 것 좋습니다!!
근데 그 누누가 2코스트 챔피언인 것 같은데, Assertions.assertThat(championTest).isNull(); 부분이 아래와 같이 되어야하지 않나요?
Assertions.assertThat(championTest).isNotNull();

작성하신 클래스에서 메소드 왼쪽에 보면 초록색 실행 버튼 있습니다. 이를 통해서 테스트 실행해보셨을까요?

Comment on lines +39 to +42
Assertions.assertThat(synergyTest).isNull();
Assertions.assertThat(synergyTest2).isNull();
Assertions.assertThat(synergyTest3).isNull();
Assertions.assertThat(synergyTest4).isNotNull();
Copy link
Member

Choose a reason for hiding this comment

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

요기도 마찬가지로 다시 작성한 뒤에, 테스트 실행해보시면 좋을 것 같아요!
수고하셨습니다. 덕분에 요즘 시너지에 대해서도 알고 좋네요ㅋㅋ

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.

2 participants