-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refacotr/#148/mypage-optimization' of https://github.co…
…m/dnd-side-project/dnd-11th-3-backend into refacotr/#148/mypage-optimization
- Loading branch information
Showing
6 changed files
with
141 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/dnd/gongmuin/answer/repository/AnswerSimpleQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.dnd.gongmuin.answer.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.dnd.gongmuin.answer.domain.Answer; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class AnswerSimpleQueryRepository { | ||
|
||
private final EntityManager em; | ||
|
||
public Optional<Answer> findAnswerById(Long answerId) { | ||
Answer answer = em.createQuery( | ||
"select a from Answer a" + | ||
" join fetch a.member m" + | ||
" where a.id = :answerId", Answer.class | ||
) | ||
.setParameter("answerId", answerId) | ||
.getSingleResult(); | ||
return Optional.of(answer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ain/java/com/dnd/gongmuin/question_post/repository/QuestionPostSimpleQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.dnd.gongmuin.question_post.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.dnd.gongmuin.question_post.domain.QuestionPost; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class QuestionPostSimpleQueryRepository { | ||
|
||
private final EntityManager em; | ||
|
||
public Optional<QuestionPost> findQuestionPostById(Long questionPostId) { | ||
QuestionPost questionPost = em.createQuery( | ||
"select q from QuestionPost q" + | ||
" join fetch q.member m" + | ||
" where q.id = :questionPostId", QuestionPost.class | ||
) | ||
.setParameter("questionPostId", questionPostId) | ||
.getSingleResult(); | ||
return Optional.of(questionPost); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters