이용일-sprint6#128
Hidden character warning
Conversation
| @Query("SELECT DISTINCT c FROM Channel c " + | ||
| "LEFT JOIN FETCH c.messages " + | ||
| "LEFT JOIN FETCH c.readStatuses") | ||
| List<Channel> findAllWithMessagesAndReadStatuses(); |
There was a problem hiding this comment.
두 개의 컬렉션(messages와 readStatuses)을 동시에 LEFT JOIN FETCH하고 있습니다. Hibernate에서 List 타입의 컬렉션 두 개를 동시에 FETCH JOIN하면 MultipleBagFetchException이 발생합니다.
@Query("SELECT DISTINCT c FROM Channel c " +
"LEFT JOIN FETCH c.messages " +
"LEFT JOIN FETCH c.readStatuses")
List<Channel> findAllWithMessagesAndReadStatuses();해결 방법으로는 다음 중 하나를 추천합니다:
- 컬렉션 중 하나를
Set으로 변경 - 두 번의 쿼리로 분리 (첫 번째 쿼리에서 messages FETCH, 두 번째에서 readStatuses FETCH)
default_batch_fetch_size설정을 활용하여 FETCH JOIN 없이 조회 (현재 100으로 설정되어 있으므로 FETCH JOIN 제거만으로도 가능)
| ); | ||
|
|
||
|
|
||
| CREATE TABLE user_statuses |
There was a problem hiding this comment.
user_statuses 테이블이 DDL 파일 내에서 두 번 정의되어 있습니다.
| private List<ReadStatus> readStatuses = new ArrayList<>(); | ||
|
|
||
| @OneToMany(mappedBy = "author") | ||
| private List<Message> messages = new ArrayList<>(); |
There was a problem hiding this comment.
클래스 다이어그램에서 Message -> User 관계는 단방향(Message에서 User로)으로 정의되어 있으나, User 엔티티에 @OneToMany(mappedBy = "author") List<Message> messages가 추가되어 양방향으로 구현되었습니다. 마찬가지로 readStatuses도 User 쪽에 양방향으로 설정되어 있습니다.
클래스 다이어그램 기준에서 User -> Message 역방향 참조가 명시되어 있지 않으므로 messages 필드는 제거하는 것이 다이어그램 준수에 더 부합합니다. readStatuses는 cascade 처리를 위해 유지할 수 있지만, 꼭 필요한 경우가 아니라면 불필요한 양방향 관계는 피하는 것이 좋습니다.
| ChannelType type, | ||
| String name, | ||
| String description, | ||
| List<UserDto> participantIds, |
There was a problem hiding this comment.
클래스 다이어그램에서 ChannelDto의 participants 필드는 List<UserDto> 타입이지만, 실제 필드명이 participantIds로 되어 있습니다. ChannelMapper에서도 participantIds 타겟에 List<UserDto>를 매핑하고 있어 필드명이 혼란스럽습니다.
이런 DTO 정의가 API 스펙과 맞지 않으면, FE 동작에 문제가 생길 수 있습니다.
| try { | ||
| return Files.newInputStream(filePath); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); |
요구사항
기본
데이터베이스: discodeit
유저: discodeit_user
패스워드: discodeit1234
심화
-오프셋 페이지네이션 : 데이터의 위치(offset)를 기준으로 특정 구간을 가져오는 방식
-커서 페이지네이션 : 마지막으로 조회한 데이터의 값(cursor)을 기준으로 다음 데이터를 가져오는 방식
주요 변경사항
스크린샷
멘토에게