Skip to content

[BE-30] 레코드 작성, 레코드 조회#47

Merged
kdomo merged 6 commits intodevelopfrom
feature/BE-30
Dec 29, 2022
Merged

[BE-30] 레코드 작성, 레코드 조회#47
kdomo merged 6 commits intodevelopfrom
feature/BE-30

Conversation

@kdomo
Copy link
Copy Markdown
Member

@kdomo kdomo commented Dec 28, 2022

관련 이슈 번호

설명

레코드 작성과 레코드 조회 API 구현 하였습니다.
이미지 업로드 작업 시 RecordService에서 추가 해야합니다.

Entity에서 여러개의 컬럼이 FetchType.LAZY가 걸려있을 때
Fetch join을 사용하니 여러개가 중첩된 형태의 조인 쿼리가 날라가는걸 발견하였습니다.
Fetch join을 사용하지 않고 조회 vs Fetch join을 사용하고 조회
어떤것이 더 검색 성능이 좋을까가 궁금하여 테스트 해 본 결과
동일 id에 대한 반복테스트는 fetch join을 적용시킨것이 더 빨랐지만,
랜덤한 10개의 id에 대한 테스트는 fetch join을 적용시키지 않은 것이 더 빨랐기 때문에
fetch join 적용을 해제 하였습니다.

변경사항

  • RecordExceptionHandler 정의
  • CustomException 생성
  • Record Entity 정적 팩토리 메서드로 객체 생성
  • Record에 지연로딩으로 되어있어 레코드 조회 시 쿼리가 계속 날라가서 패치조인 적용

질문사항

@ApiParam @RequestPart(required = false) List<MultipartFile> files
) {
return null;
return new ResponseEntity<>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return ResponseEntity.status(HTTPSTATUS.CREATED).body(writeRecord(dto)); 이거로 가시죵

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

status를 붙여야 되는구나 감사합니다

public interface RecordRepository extends JpaRepository<Record, Long> {
// @Query("select r from RECORD r join fetch r.writer join fetch r.recordColor join fetch r.recordIcon"
// + " where r.id = :id")
Optional<Record> findById(Long id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

패치조인 적용 안한다면 주석처리해서 기본 생성된거로 쓰는거로 하시죠

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

저걸 자꾸 주석을 빼먹네요 ㅋㅋㅋㅋ

@kdomo kdomo merged commit 9ae3f8f into develop Dec 29, 2022
@kdomo kdomo deleted the feature/BE-30 branch December 29, 2022 06:17
@kdomo kdomo restored the feature/BE-30 branch January 1, 2023 14:59
@kdomo kdomo deleted the feature/BE-30 branch January 1, 2023 15:00
@kdomo kdomo mentioned this pull request Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants