Skip to content

[FIX]: 예약 내역 조회 에러 Transactional(readOnly = true) 어노테이션 추가#155

Merged
zerochani merged 1 commit into
developfrom
fixError
Apr 13, 2026
Merged

[FIX]: 예약 내역 조회 에러 Transactional(readOnly = true) 어노테이션 추가#155
zerochani merged 1 commit into
developfrom
fixError

Conversation

@zerochani
Copy link
Copy Markdown
Contributor

@zerochani zerochani commented Apr 12, 2026

💡 작업 개요

  • 예약 내역 조회 API에서 발생하는 500 에러를 수정했습니다. BookingQueryServiceImpl.getBookingList() 메서드에 누락된 @transactional 어노테이션을 추가하여 LAZY 로딩 시 발생하는LazyInitializationException을 해결했습니다.

✅ 작업 내용

  • 기능 개발
  • 버그 수정
  • 리팩토링
  • 주석/포맷 정리
  • 기타 설정

🧪 테스트 내용

  • 서버 재시작 후 GET /api/v1/users/bookings API 정상 작동 확인 필요

📝 기타 참고 사항

  • 근본 원인: Git 히스토리 확인 결과, 해당 메서드는 커밋 e53a892에서 처음 작성될 때부터 @transactional 어노테이션이 누락되어 있었습니다.
    • 이전에 작동한 이유: Spring Boot의 open-in-view 기본 설정으로 인해 HTTP 요청이 끝날 때까지 JPA 세션이 유지되었거나, 실제 예약 데이터가 없어서 LAZY 로딩이 실행되지 않았을 가능성이 있습니다.
    • 수정 파일: src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java:174
    • 일관성: 같은 클래스 내 다른 조회 메서드들(getAvailableTimeSlots, getAvailableTables, getBookingDetail)은 모두 @transactional(readOnly = true)를 사용하고 있어 일관성을 맞췄습니다.

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 데이터 조회 성능 최적화를 위한 내부 개선 사항이 적용되었습니다.

참고: 이번 업데이트는 사용자에게 보이는 기능 변화는 없습니다.

@zerochani zerochani requested review from SungMinju and twodo0 April 12, 2026 16:07
@zerochani zerochani self-assigned this Apr 12, 2026
@zerochani zerochani added bug Something isn't working fix labels Apr 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

📝 Walkthrough

개요

BookingQueryServiceImplgetBookingList() 메서드에 @Transactional(readOnly = true) 애노테이션을 추가하여 트랜잭션 읽기 전용 의미론을 명시적으로 설정했습니다. 메서드의 로직, 제어 흐름, 매개변수, 반환 구조는 변경되지 않았습니다.

변경사항

Cohort / File(s) 요약
트랜잭션 애노테이션 추가
src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java
getBookingList() 메서드에 @Transactional(readOnly = true) 애노테이션 추가하여 읽기 전용 트랜잭션 명시

예상 코드 리뷰 소요 시간

🎯 1 (Trivial) | ⏱️ ~2분

추천 리뷰어

  • SungMinju
  • twodo0

🐰 조용히 읽기만 하는 메서드여,
트랜잭션 배지를 달았네.
데이터베이스 성능 향상하고,
의도는 더욱 명확하게!
한 줄의 변화, 큰 의미를 담아. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 주요 변경사항(예약 내역 조회 에러 수정을 위한 @Transactional 어노테이션 추가)을 명확하게 설명하고 있으며, 변경사항의 핵심을 효과적으로 요약하고 있습니다.
Description check ✅ Passed PR 설명은 템플릿의 모든 필수 섹션(작업 개요, 작업 내용, 테스트 내용, 기타 참고 사항)을 포함하고 있으며, 상세한 배경 정보와 원인 분석을 제공하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fixError

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.

Copy link
Copy Markdown

@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/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java (1)

183-187: ⚠️ Potential issue | 🟠 Major

status 파싱 실패(IllegalArgumentException)를 도메인 예외로 변환해야 합니다.

Line [186]의 BookingStatus.valueOf(status)는 잘못된 문자열 입력 시 IllegalArgumentException을 던져 500으로 노출될 수 있습니다. 허용값 검증 후 BookingException으로 매핑해 일관된 에러 응답을 반환하세요. (ALL 비교도 equalsIgnoreCase 권장)

As per coding guidelines, "1. 예외 처리 - RuntimeException을 남발하지 않고, 의미 있는 커스텀 예외를 사용하는지 검토." 그리고 "5. 입력 검증 및 보안 - @Valid, Bean Validation 등을 통한 입력값 검증이 되어 있는지."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java`
around lines 183 - 187, Validate and normalize the incoming status string in
BookingQueryServiceImpl before calling BookingStatus.valueOf: use
equalsIgnoreCase for the "ALL" check, and wrap the conversion in a try/catch
that catches IllegalArgumentException and throws a domain BookingException (with
a clear message about invalid status) so invalid inputs map to a controlled
domain error; update the branch that currently calls
BookingStatus.valueOf(status) to perform this validation/exception mapping and
then call bookingRepository.findAllByUserAndStatus(user, bookingStatus,
pageRequest).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java`:
- Line 176: In BookingQueryServiceImpl, the PageRequest.of(page, 10,
Sort.by("bookingDate").descending()) call can throw a runtime exception if the
input variable page is null or negative; update the method that constructs the
PageRequest to validate the page parameter (check if page == null or page < 0)
and either normalize it to a safe default (e.g., page = 0) or throw a controlled
validation exception (e.g., BadRequestException or a custom
PageParameterException) which your controller/exception handler maps to HTTP
400, then use the validated/normalized page when calling PageRequest.of(...) so
the API no longer results in a 500 for invalid page inputs.

---

Outside diff comments:
In
`@src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java`:
- Around line 183-187: Validate and normalize the incoming status string in
BookingQueryServiceImpl before calling BookingStatus.valueOf: use
equalsIgnoreCase for the "ALL" check, and wrap the conversion in a try/catch
that catches IllegalArgumentException and throws a domain BookingException (with
a clear message about invalid status) so invalid inputs map to a controlled
domain error; update the branch that currently calls
BookingStatus.valueOf(status) to perform this validation/exception mapping and
then call bookingRepository.findAllByUserAndStatus(user, bookingStatus,
pageRequest).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f257947-bad3-4f89-bc99-9bd3ae2ab915

📥 Commits

Reviewing files that changed from the base of the PR and between e9ff9e3 and 4e55dfe.

📒 Files selected for processing (1)
  • src/main/java/com/eatsfine/domain/booking/service/BookingQueryServiceImpl.java

Copy link
Copy Markdown
Contributor

@SungMinju SungMinju left a comment

Choose a reason for hiding this comment

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

확인했습니다!

@zerochani zerochani merged commit ba3ece4 into develop Apr 13, 2026
2 checks passed
zerochani added a commit that referenced this pull request Apr 13, 2026
* Create bug report template in Korean

Added a bug report template in Korean with fields for description, reproduction steps, expected behavior, actual behavior, screenshots/logs, root cause analysis, and references.

* [FIX]: 예약 내역 조회 에러 Transactional(readOnly = true) 어노테이션 추가 (#155)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants