Open
Conversation
sebeeeen
commented
Oct 2, 2024

jjunhub
reviewed
Oct 8, 2024
Comment on lines
+18
to
+28
| @Column(name = "School_id") | ||
| private Long id; | ||
|
|
||
| @Column(name = "School_name") | ||
| private String schoolName; | ||
|
|
||
| @Column(name = "Total_students") | ||
| private int totalStudents; | ||
|
|
||
| @Column(name = "Average_grade") | ||
| private double averageGrade; |
Member
There was a problem hiding this comment.
잘 작성해주셨습니다!
틀린 것은 아니지만! 관례상 자주 사용되는 패턴이 있습니다.
MySQL에서는 Column 이름을 snake_case로 작성하는 것이 일반적입니다.
실제로도 @Column(name = ~)를 생략하게 되면, 이를 snake_case로 변경하여 DB에 생성합니다.
그리고 table명_id 구조로 PK를 작성하는 편이기도 합니다.
따라서 아래처럼 써보시는 것이 어떠할까 싶네용
Suggested change
| @Column(name = "School_id") | |
| private Long id; | |
| @Column(name = "School_name") | |
| private String schoolName; | |
| @Column(name = "Total_students") | |
| private int totalStudents; | |
| @Column(name = "Average_grade") | |
| private double averageGrade; | |
| @Column(name = "school_id") | |
| private Long id; | |
| @Column(name = "school_name") | |
| private String schoolName; | |
| @Column(name = "total_students") | |
| private int totalStudents; | |
| @Column(name = "average_grade") | |
| private double averageGrade; |
jjunhub
reviewed
Oct 8, 2024
Comment on lines
+59
to
+82
| @DisplayName("SchoolName과 TotalStudent를 이용한 찾기") | ||
| @Test | ||
| void testFindBySchoolNameAndTotalStudents() { | ||
| // Given | ||
| School school1 = School.builder() | ||
| .schoolName("아주대학교") | ||
| .totalStudents(13884) | ||
| .averageGrade(4.3) | ||
| .build(); | ||
| School school2 = School.builder() | ||
| .schoolName("서울대학교") | ||
| .totalStudents(35000) | ||
| .averageGrade(4.0) | ||
| .build(); | ||
| schoolRepository.saveAll(List.of(school1, school2)); | ||
|
|
||
| // When | ||
| School result1 = schoolRepository.findBySchoolNameAndTotalStudents("아주대학교", 13884); | ||
| School result2 = schoolRepository.findBySchoolNameAndTotalStudents("서울대학교", 35000); | ||
|
|
||
| // Then. | ||
| Assertions.assertThat(result1).isNotNull(); | ||
| Assertions.assertThat(result2.getSchoolName()).isEqualTo("서울대학교"); | ||
| Assertions.assertThat(result2.getTotalStudents()).isEqualTo(35000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.