-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 엔티티가 BaseEntity를 상속하도록 #524
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
refactor: 엔티티가 BaseEntity를 상속하도록 #524
Conversation
Walkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java (1)
38-38: 수동 타임스탬프 관리 제거 필요 (BaseEntity와 충돌)충돌 발견:
- Line 38: 수동으로 정의된
createdAt필드가 있습니다.- Lines 65-68:
@PrePersist에서createdAt을 수동으로 설정합니다.- 문제점: BaseEntity가 JPA Auditing을 통해
created_at/updated_at을 자동 관리하므로, 수동 관리 코드와 충돌합니다.예상되는 영향:
- JPA 매핑 오류 또는 중복 컬럼 문제가 발생할 수 있습니다.
- 마이그레이션 V33에서 추가한
created_at컬럼은 BaseEntity가 관리해야 합니다.다음 diff를 적용하여 수동 타임스탬프 관리를 제거하세요:
- @Column(nullable = false) - private ZonedDateTime createdAt; - @Column private ZonedDateTime confirmedAt;- @PrePersist - public void onPrePersist() { - this.createdAt = ZonedDateTime.now(UTC).truncatedTo(MICROS); // 나노초 6자리 까지만 저장 - } - public void confirm(VerifyStatus status) {참고:
confirmedAt,checkedAtByMentor,checkedAtByMentee는 도메인 로직에 필요한 별도 타임스탬프이므로 유지해야 합니다.Also applies to: 65-68
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
src/main/java/com/example/solidconnection/application/domain/Application.java(2 hunks)src/main/java/com/example/solidconnection/application/domain/Gpa.java(2 hunks)src/main/java/com/example/solidconnection/application/domain/LanguageTest.java(2 hunks)src/main/java/com/example/solidconnection/community/board/domain/Board.java(2 hunks)src/main/java/com/example/solidconnection/community/post/domain/PostImage.java(2 hunks)src/main/java/com/example/solidconnection/community/post/domain/PostLike.java(2 hunks)src/main/java/com/example/solidconnection/location/country/domain/Country.java(2 hunks)src/main/java/com/example/solidconnection/location/country/domain/InterestedCountry.java(2 hunks)src/main/java/com/example/solidconnection/location/region/domain/InterestedRegion.java(2 hunks)src/main/java/com/example/solidconnection/location/region/domain/Region.java(2 hunks)src/main/java/com/example/solidconnection/mentor/domain/Channel.java(2 hunks)src/main/java/com/example/solidconnection/mentor/domain/Mentor.java(2 hunks)src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java(2 hunks)src/main/java/com/example/solidconnection/news/domain/LikedNews.java(2 hunks)src/main/java/com/example/solidconnection/report/domain/Report.java(2 hunks)src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java(2 hunks)src/main/java/com/example/solidconnection/university/domain/LanguageRequirement.java(2 hunks)src/main/java/com/example/solidconnection/university/domain/LikedUnivApplyInfo.java(2 hunks)src/main/java/com/example/solidconnection/university/domain/UnivApplyInfo.java(2 hunks)src/main/java/com/example/solidconnection/university/domain/University.java(2 hunks)src/main/resources/db/migration/V33__add_baseentity_related_fields.sql(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (19)
src/main/java/com/example/solidconnection/location/region/domain/InterestedRegion.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.InterestedRegion 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 표준 엔티티 패턴을 따르고 있습니다.
Also applies to: 25-25
src/main/java/com/example/solidconnection/mentor/domain/Channel.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.Channel 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 표준 엔티티 패턴을 따르고 있습니다.
Also applies to: 30-30
src/main/java/com/example/solidconnection/location/region/domain/Region.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.Region 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 자연키를 사용하는 참조 데이터 엔티티 패턴을 따르고 있습니다.
Also applies to: 16-16
src/main/java/com/example/solidconnection/university/domain/LanguageRequirement.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.LanguageRequirement 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 표준 엔티티 패턴을 따르고 있습니다.
Also applies to: 23-23
src/main/java/com/example/solidconnection/location/country/domain/InterestedCountry.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.InterestedCountry 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 표준 엔티티 패턴을 따르고 있습니다.
Also applies to: 25-25
src/main/java/com/example/solidconnection/community/board/domain/Board.java (1)
3-3: BaseEntity 상속이 올바르게 적용되었습니다.Board 엔티티에 BaseEntity 상속이 정상적으로 추가되었으며, 자연키를 사용하는 참조 데이터 엔티티 패턴을 따르고 있습니다.
Also applies to: 13-13
src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java (1)
6-6: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 6)
- 클래스 선언 업데이트 (Line 31):
Mentoring extends BaseEntity이제 공통 타임스탬프 필드가 상속을 통해 관리됩니다.
Also applies to: 31-31
src/main/java/com/example/solidconnection/community/post/domain/PostLike.java (1)
3-3: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 3)
- 클래스 선언 업데이트 (Line 19):
PostLike extends BaseEntity깔끔하게 적용되었습니다. 이제 공통 타임스탬프 필드가 자동으로 관리됩니다.
Also applies to: 19-19
src/main/java/com/example/solidconnection/university/domain/UnivApplyInfo.java (1)
3-3: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 3)
- 클래스 선언 업데이트 (Line 30):
UnivApplyInfo extends BaseEntity- 테이블 매핑 확인:
@Table(name = "university_info_for_apply")가 마이그레이션 스크립트의 테이블명과 일치합니다.적용이 올바르게 완료되었습니다.
Also applies to: 30-30
src/main/java/com/example/solidconnection/community/post/domain/PostImage.java (1)
3-3: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 3)
- 클래스 선언 업데이트 (Line 18):
PostImage extends BaseEntity깔끔하게 적용되었습니다.
Also applies to: 18-18
src/main/java/com/example/solidconnection/application/domain/Application.java (1)
5-5: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 5)
- 클래스 선언 업데이트 (Line 39):
Application extends BaseEntity- 테이블 매핑 확인: 기본 테이블명 "application"이 마이그레이션 스크립트와 일치합니다.
적용이 올바르게 완료되었습니다.
Also applies to: 39-39
src/main/java/com/example/solidconnection/report/domain/Report.java (1)
3-3: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 3)
- 클래스 선언 업데이트 (Line 26):
Report extends BaseEntity깔끔하게 적용되었습니다.
Also applies to: 26-26
src/main/java/com/example/solidconnection/news/domain/LikedNews.java (1)
3-3: BaseEntity 상속 적용 완료변경 사항:
- BaseEntity 임포트 추가 (Line 3)
- 클래스 선언 업데이트 (Line 26):
LikedNews extends BaseEntity깔끔하게 적용되었습니다.
Also applies to: 26-26
src/main/resources/db/migration/V33__add_baseentity_related_fields.sql (1)
1-80: 마이그레이션 스크립트 머지 승인
- 스키마 변경: 20개 테이블에
created_at,updated_at컬럼(DATETIME(6)) 추가- BaseEntity 자동 관리:
@PrePersist/@PreUpdate메서드로 타임스탬프 설정 로직 정상 작동- JPA Auditing: 애플리케이션에
@EnableJpaAuditing설정 확인 완료추가 조치 없이 머지 진행하세요.
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java (1)
3-3: 변경 사항 및 마이그레이션 확인 완료
- BaseEntity import 추가
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java 3행: com.example.solidconnection.common.BaseEntity 임포트- 클래스 상속 변경
24행: public class Mentor → public class Mentor extends BaseEntity 로 수정 (생성·수정 시점 추적)- DB 마이그레이션 반영 확인
src/main/resources/db/migration/V33__add_baseentity_related_fields.sql 45행에 ALTER TABLE mentor 포함 확인src/main/java/com/example/solidconnection/university/domain/LikedUnivApplyInfo.java (1)
3-3: ✅ BaseEntity 상속 및 마이그레이션 확인 완료
BaseEntity import 추가
src/main/java/com/example/solidconnection/university/domain/LikedUnivApplyInfo.java라인 3에import com.example.solidconnection.common.BaseEntity;를 추가했습니다.클래스 선언 확장
- 클래스 선언을
public class LikedUnivApplyInfo extends BaseEntity로 변경(라인 29)하여 생성일시·수정일시 자동 관리가 가능합니다.마이그레이션 스크립트 적용 확인
src/main/resources/db/migration/V33__add_baseentity_related_fields.sql파일 69행에ALTER TABLE liked_university_info_for_apply구문이 포함된 것을 확인했습니다.좋아요 정보의 생성 및 수정 시점이 정상적으로 관리됩니다.
src/main/java/com/example/solidconnection/location/country/domain/Country.java (1)
3-3: BaseEntity 확장 및 마이그레이션 확인 완료변경 사항을 정리하면 다음과 같습니다:
BaseEntity import 추가
src/main/java/com/example/solidconnection/location/country/domain/Country.java 파일 3번째 줄에import com.example.solidconnection.common.BaseEntity;를 추가했습니다.클래스 선언에 BaseEntity 상속 적용
같은 파일 16번째 줄에서public class Country를public class Country extends BaseEntity로 변경했습니다.마이그레이션 스크립트 반영 확인
src/main/resources/db/migration/V33__add_baseentity_related_fields.sql 파일 25번째 줄에ALTER TABLE country구문이 포함된 것을 확인했습니다.모든 변경 사항이 의도대로 반영되었습니다.
src/main/java/com/example/solidconnection/university/domain/University.java (1)
3-3: 확인 완료: 대학 엔티티 마이그레이션 반영 여부
- V33__add_baseentity_related_fields.sql 파일 77행에서
ALTER TABLE university구문을 확인했습니다.- 명시적
@Table어노테이션 미사용 시 JPA 기본 테이블명university가 정상 적용됩니다.BaseEntity 상속으로 추가된 생성·수정 타임스탬프 필드가 마이그레이션에 올바르게 반영되었음을 확인했습니다.
src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java (1)
3-3: 검증 완료: BaseEntity 상속 및 마이그레이션 반영 확인
변경 사항은 다음과 같습니다:
- BaseEntity import 추가
com.example.solidconnection.common.BaseEntity임포트가 추가되었습니다.- 클래스 선언 변경
public class SiteUser→public class SiteUser extends BaseEntity로 수정되었습니다.
nicknameModifiedAt및quitedAt필드는 특정 이벤트 추적용으로, BaseEntity의created_at/updated_at과 역할이 달라 함께 공존 가능합니다.
V33 마이그레이션 파일 61번 라인에서ALTER TABLE site_user구문이 포함된 것을 확인했습니다.
src/main/java/com/example/solidconnection/application/domain/Gpa.java
Outdated
Show resolved
Hide resolved
src/main/java/com/example/solidconnection/application/domain/LanguageTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~ 코드래빗 의견 반영하고 flyway도 수정해주시면 승인하겠습니다!
BaseEntity 상속이 불필요한 엔티티가 있을까요 ? 저는 없다고 생각하고, 있어도 나쁠 건 없다고 생각하는데, 다른 의견이 있으신지 궁금합니다.
이거에 대해선 region, country, board같은 enum 느낌이 강한 entity에 createdAt같은 필드가 필요할 일이 없을 거 같다는 생각이 들었습니다!
|
개인적으로 BaseEntity(createdAt, modifiedAt)의 정보는 유저의 활동과 연관이 있는 Entity가 필요하다고 생각합니다! 때문에 저도 region, country, board와 같이 유저의 활동과 연관이 없다면 필요하진 않다고 느껴지네요 ㅎㅎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/resources/db/migration/V34__add_baseentity_related_fields.sql (1)
57-67: 정렬을 다른 구문과 맞춰주세요.
파일 전체가 4칸 공백으로 들여쓰기 되어 있는데, Line 57~67 구문만 탭 4개가 들어가 있어 들여쓰기 폭이 달라져요. 동일한 공백 들여쓰기(4칸)로 맞춰 주시면 가독성이 좋아집니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/resources/db/migration/V34__add_baseentity_related_fields.sql(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
Gyuhyeok99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~
fix: PostRepository & CommentRepository의 일부 메서드의 정렬 순서 오류 해결 (#522) refactor: 이메일 유니크키 제거 refactor: 엔티티가 BaseEntity를 상속하도록 (#524) fix: BaseEntity 관련 마이그레이션 파일 수정 (#530) feat: 멘토 승격 api 구현 (#532) fix: 대학교 중복 오류 수정 (#510) refactor: 불필요한 로그 삭제 (#543) fix: 운영환경 8081 포트 설정 추가 (#542) fix: dev환경 디비명 변경 (#546) refactor: 불필요한 로그 삭제 (#547) refactor: 학기를 테이블로 관리하도록 변경 (#526) refactor: 모의지원 시 지원한 대학 정보 응답 추가 (#539)
관련 이슈
작업 내용
모든 엔티티가
BaseEntity를 상속하도록 리팩토링합니다.특이 사항
리뷰 요구사항 (선택)
BaseEntity상속이 불필요한 엔티티가 있을까요 ? 저는 없다고 생각하고, 있어도 나쁠 건 없다고 생각하는데, 다른 의견이 있으신지 궁금합니다.