Skip to content

Conversation

@patulus
Copy link
Member

@patulus patulus commented Jan 6, 2026

⭐️ 관련 이슈

closed #2

🚩 작업 요약

1️⃣ RoomTag 엔티티 equals()hashCode() 메서드 반환 값 수정

  • 기존에는 RoomTagId 객체 자체를 반환했어요. 그런데 RoomTagId 내부의 roomId와 tagId가 영속성 컨텍스트에 의해 값이 채워지기 전까지는 null이어서 서로 같은 객체(처음 삽입된 객체)와 같다고 취급했어요.
  • 이를 해결하기 위해 RoomTag 엔티티의 equals()hashCode() 메서드를 수정해 동등성 비교가 요구사항과 일치하도록 수정했어요.

@patulus patulus self-assigned this Jan 6, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

Summary by CodeRabbit

릴리스 노트

  • Refactor
    • Room music tag의 동등성 판단 및 해시 생성 로직을 업데이트했습니다. 이제 비교 기준이 고유 ID가 아닌 방과 태그 기준으로 변경되어, 중복 판단 및 컬렉션 처리와 같은 관련 동작에 영향이 있을 수 있습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

RoomMusicTag 엔티티의 동등성 계약이 변경되었습니다. equals(Object)에서 id 대신 room과 tag 필드를 비교하도록 변경되었고, hashCode()는 room과 tag 기반 해시를 반환하도록 수정되었습니다.

Changes

Cohort / File(s) 변경 요약
RoomMusicTag 동등성 변경
src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
- equals(Object obj)가 패턴 매칭을 사용해 캐스트한 후 roomtag 필드로 동등성 비교하도록 변경됨.
- hashCode()roomtag 필드를 사용해 해시 계산하도록 변경됨.
- 패턴 변수명이 내부적으로 that으로 변경됨(동작상 차이 없음).
검토 포인트: 기존 id 기반 동등성 의존 코드, 컬렉션에서의 사용(Map/Set 등), equals/hashCode 일관성 확인.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 사항의 핵심을 명확하게 설명하고 있으며, RoomTag 엔티티의 equals() 및 hashCode() 메서드 수정이라는 주요 변경 사항을 직관적으로 전달합니다.
Description check ✅ Passed PR 설명이 관련 이슈, 작업 요약을 포함하고 있으나, 템플릿의 '📋 요구 사항' 섹션이 누락되어 있습니다. 핵심 내용은 충분히 설명되었습니다.
Linked Issues check ✅ Passed PR이 Issue #2의 요구사항을 충족합니다. 여러 태그가 하나만 저장되는 버그는 equals()와 hashCode()의 불완전한 구현으로 인한 동등성 판단 오류가 원인이었으며, 본 PR이 이를 해결합니다.
Out of Scope Changes check ✅ Passed PR의 모든 변경사항이 Issue #2 해결을 위한 범위 내에 있으며, RoomMusicTag 엔티티의 equals()와 hashCode() 메서드 수정에만 집중하고 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-#2

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39e6216 and b671a92.

📒 Files selected for processing (1)
  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
⏰ 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

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @patulus, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 RoomMusicTag 엔티티의 equals() 및 hashCode() 메서드 구현을 개선하여 객체 동등성 비교의 정확성을 확보합니다. 이는 영속성 컨텍스트 초기화 과정에서 발생할 수 있는 null 값으로 인한 잘못된 비교 문제를 해결하고, 엔티티의 올바른 동작을 보장합니다.

Highlights

  • RoomMusicTag 엔티티 동등성 비교 로직 개선: RoomMusicTag 엔티티의 equals() 및 hashCode() 메서드가 RoomTagId 객체 대신 Room 및 Tag 객체를 사용하여 동등성을 정확하게 비교하도록 수정되었습니다. 기존에는 RoomTagId 내부 필드가 영속성 컨텍스트에 의해 채워지기 전까지 null이어서 잘못된 동등성 판단을 초래했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

PR에서 설명해주신대로, 영속화 전 엔티티의 동등성 비교 문제를 해결하기 위해 equals 메서드를 수정한 것은 좋은 접근입니다. RoomTagId 대신 비즈니스 키에 해당하는 RoomMusicTag 엔티티를 직접 비교하는 것이 올바른 방향입니다. 다만, hashCode 메서드 구현에 equals와 동등성 비교에 사용되는 필드가 모두 포함되지 않은 점이 우려됩니다. 이 부분에 대한 수정 의견을 리뷰 코멘트로 남겼습니다. equals/hashCode 계약을 올바르게 지키는 것은 객체의 동등성을 다루는 데 매우 중요하므로 확인 부탁드립니다.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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/queuing/core/room/domain/entity/RoomMusicTag.java (1)

45-55: RoomMusicTag의 equals-hashCode 계약 위반 수정 필요

RoomMusicTag 엔티티가 적절한 equals()/hashCode()를 구현하고 있음은 확인되었습니다. 그러나 RoomMusicTag의 구현에 심각한 문제가 있습니다.

현재 구현에서 equals() 메서드는 room과 tag 모두를 비교하지만(55줄), hashCode() 메서드는 tag만 해싱합니다(59줄):

return Objects.hash(this.getTag());  // tag만 고려

이는 Java의 equals-hashCode 계약을 위반합니다. 동일한 room ID와 tag ID를 가진 두 객체는 equals()가 true를 반환하지만, room이 다르면 equals()는 false를 반환하면서 동일한 hashCode() 값을 가질 수 있습니다. 이로 인해 HashSet, HashMap 등 해시 기반 컬렉션에서 예기치 않은 동작이 발생할 수 있습니다.

hashCode() 구현을 수정하여 room과 tag 모두를 반영하도록 변경하시기 바랍니다:

return Objects.hash(this.getRoom(), this.getTag());

또한 equals() 메서드에 @Override 어노테이션을 추가하시기 바랍니다.

🤖 Fix all issues with AI Agents
In @src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java:
- Around line 57-60: hashCode() currently only hashes getTag() while equals()
compares both getRoom() and getTag(), causing inconsistent hash distribution;
update RoomMusicTag.hashCode() to include the same fields used in equals (e.g.,
this.getRoom() and this.getTag()) so the hashCode and equals contracts match,
using Objects.hash(...) with both identifiers (or room id + tag) to avoid
excessive hash collisions.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a28e5f4 and 39e6216.

📒 Files selected for processing (1)
  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
🧰 Additional context used
📓 Path-based instructions (3)
**/*.java

📄 CodeRabbit inference engine (.rules/intellij-formatter.xml)

**/*.java: Use LF (Line Feed) as the line separator
Use 4 spaces for indentation (not tabs) in Java files
Set tab size to 4 characters in Java files
Set continuation indent size to 4 spaces in Java files
Limit line length to 120 characters
Add a space after line comments (// )
Do not keep line comments at the first column; add space before them
Do not keep control statements on a single line
Keep a maximum of 1 blank line in code declarations
Keep a maximum of 1 blank line in code sections
Keep a maximum of 1 blank line before closing braces
Do not align multiline parameters
Do not add space after type casts
Add space before array initializer left braces
Wrap call parameters when they exceed line length
Wrap method parameters when they exceed line length
Wrap extends list when it exceeds line length
Wrap throws list only in extreme cases
Wrap extends keyword when the extends list exceeds line length
Wrap method call chains only in extreme cases
Wrap binary operations when they exceed line length
Place binary operation signs on the next line when wrapping
Wrap ternary operations when they exceed line length
Wrap array initializers when they exceed line length
Enable wrapping for comments that exceed the line limit
Enable Javadoc formatting
Enable formatter tags (@Formatter:off/@Formatter:on) to control code formatting
Organize imports with static imports first, followed by java., javax./jakarta., org., net., com., lombok.*, and custom packages (com.example, com.patulus, university.likelion) in that order
Use explicit imports instead of wildcard imports for more than 1 named import
Use explicit imports instead of wildcard imports for more than 99 class imports from a single package

Files:

  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java

⚙️ CodeRabbit configuration file

**/*.java: - Review against Java 21 and the rules in /.rules/checkstyle-rules.xml.

  • Indentation: use spaces (no tabs), tab width = 4 spaces; files must end with Unix LF newline. (Team adaptation)
  • Maximum line length: 120 characters.
  • Imports: single-class imports only; allow wildcard for static imports; group imports with blank lines between sections.
  • Operators: always one space before and after; on line breaks, place operators at the start of the next line (commas stay at end of line, dots at start of new line).
  • Lambda expressions: omit parentheses for a single parameter; surround -> with spaces (param -> expression); use braces and explicit return for multi-statement bodies; choose short, clear parameter names.
  • Prefer Java 21 standard APIs over Guava.
  • Do not annotate immutable local variables with final unless required for an inner class.
  • Allow the var keyword when the value is a cast null.
  • For the complete NAVER Campus Hackday conventions, see: https://naver.github.io/hackday-conventions-java/

Files:

  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
**/*

⚙️ CodeRabbit configuration file

**/*: - For every finding, include evidence: file path(s), line number(s), rule names (e.g., Checkstyle), and links to credible docs when relevant.

  • Wrap any tokens starting with '@' (e.g., @JoinColumn) in backticks in PR comments.

Files:

  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
**/main/java/**/*.java

⚙️ CodeRabbit configuration file

**/main/java/**/*.java: - This project is mature and must preserve a stable, backward-compatible public Java API.

  • In the "Changes" section, list up to 25 changes to the public Java API that could affect end users; if none, explicitly state "No public Java API changes in this PR."
  • Define the public Java API as public/protected methods on public classes plus module-info.java.
  • Derive the list by deeply analyzing code flow, including through private methods and calls to Java 21 and Guava.
  • Report:
    • New or removed public API methods
    • Changes to return types or parameter types
    • Behavioral changes that may impact consumers
  • Use System.out.println instead of logging frameworks.
  • For performance reasons, the project prefers for-loops; do not suggest converting between loops and streams.

Files:

  • src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java
🔇 Additional comments (1)
src/main/java/queuing/core/room/domain/entity/RoomMusicTag.java (1)

1-61: Public Java API 변경 사항

본 PR에서 변경된 공개 Java API는 다음과 같습니다:

  1. RoomMusicTag.equals(Object obj): 동등성 비교 기준이 id 필드에서 roomtag 필드로 변경되었습니다. 이는 동작 변경(behavioral change)으로, 기존에 id 기반으로 동등성을 판단하던 코드에 영향을 줄 수 있습니다.

  2. RoomMusicTag.hashCode(): 해시 코드 계산 기준이 id에서 tag로 변경되었습니다. (위 리뷰에서 언급한 대로 room도 포함하도록 수정이 필요합니다.)

이 변경은 버그 수정을 위한 의도적인 동작 변경이므로, 기존 동작에 의존하던 코드가 있다면 검토가 필요합니다.

- Room::addTag 실행 시 태그가 다름에도 같은 객체로 처리되는 문제를 수정합니다.
@patulus patulus merged commit 82c9d5b into main Jan 6, 2026
3 of 4 checks passed
@patulus patulus deleted the fix/issue-#2 branch January 6, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

방 태그가 여러 개가 아닌 하나만 저장되는 문제

2 participants