Skip to content
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

Question 도메인에 QueryDsl 적용 #57

Merged
merged 24 commits into from
Dec 23, 2024
Merged

Question 도메인에 QueryDsl 적용 #57

merged 24 commits into from
Dec 23, 2024

Conversation

starwook
Copy link
Contributor

@starwook starwook commented Dec 20, 2024

연관된 이슈

https://watermelon-clap.atlassian.net/jira/software/projects/CS/boards/3?selectedIssue=CS-97

작업 내용

  • 기존 findAll, findByID등은 JpaRepository의 기본 생성 메소드 사용
  • 직접 쿼리를 구현해야하는 부분( fetch q.comments등은)
  1. queryDsl 레포지토리를 따로 구현하고
    jpaRepository가 이를 상속받아서 호출부에서 JpaRepository에 의존하거나
    (Question 도메인)
  2. queryDsl 레포지토리에 호출부가 직접적으로 의존
    (Question을 상속받고 있는 도메인)

이렇게 한 이유는

  • Question 도메인의 경우 JpaRepository를 쓰는 부분의 비중이 크기에 JpaRepository는 필수 ( 도메인 당 JpaRepository 필수 + queryDsl Interface+ Impl인 3개의 파일)
  • Question을 상속받고 있는 도메인의 경우 직접 쿼리를 구현해야하는 비중이 큼 (도메인 당 queryDsl Impl + (JpaRepository는 필수가 아님) 1or2개의 파일)
    Jpa기반많아질 수 있는 파일을 최소화 하기 위함.
    (JPA 쓰는 부분이 많다 하더라도,
    JPA가 의존하는 세부 기능 interface가 많아지면 실제 클래스도 많아짐,
    도메인별 queryDsl의 구현체는 1개, 그리고 그 구현체가 interface를 상속받는 것이 클래스 수가 적어짐)

- Persistence 모듈에 적용
- Spring Boot 2.* 버전에 맞는 설정 적용
- 자동으로 gitIgnore에 포함되도록 수정
- 해당 플러그인은 Qclass 생성을 compileJava와 분리하여 단독적으로 사용하기 위한 플러그인이지만,
 QClass 중복 생성 오류, 롬복 및 코틀린 코드 인식 불가능 오류등이 발생하여 제거
JpaConfig 클래스를 Persistence 모듈로 이동
- 기존 메소드를 MajorMultipleChoiceRepository에서 queryDsl로 구현
…MultipleCHoiceQuestionRepository에서 QueryDsl로 구현
- 모든 메소드를 QueryDsl기반의 LicenseMultipleChoiceQuestionRepository에 구현
- 스프링은 인터페이스가 아닌 구현체를 기준으로 빈을 등록되기 떄문에 제네릭 타입이 다르다고 다수의 빈이 생성되지 않음
- 쓰이지않는 JpaRepository 제거
JpaRepository를 바로 호출하도록하기 위함
@starwook starwook changed the title Cs 97 Question 도메인에 QueryDsl 적용 Dec 23, 2024
@starwook starwook merged commit 4da4fee into main Dec 23, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant