-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: commentGroup 수정하는 로직 NativeQuery로 수정
- Loading branch information
Showing
3 changed files
with
21 additions
and
11 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/main/java/com/ssafy/ssafsound/domain/comment/domain/Comment.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
28 changes: 18 additions & 10 deletions
28
src/main/java/com/ssafy/ssafsound/domain/comment/repository/CommentRepository.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
package com.ssafy.ssafsound.domain.comment.repository; | ||
|
||
import com.ssafy.ssafsound.domain.comment.domain.Comment; | ||
import org.springframework.data.domain.Pageable; | ||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import com.ssafy.ssafsound.domain.comment.domain.Comment; | ||
|
||
@Repository | ||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
@Query("SELECT c FROM comment c " + | ||
"JOIN FETCH c.commentNumber " + | ||
"JOIN FETCH c.member " + | ||
"JOIN FETCH c.commentGroup g " + | ||
"WHERE c.post.id = :postId " + | ||
"ORDER BY g.id ") | ||
List<Comment> findAllPostIdWithDetailsFetchOrderByCommentGroupId(@Param("postId") Long postId); | ||
@Query("SELECT c FROM comment c " + | ||
"JOIN FETCH c.commentNumber " + | ||
"JOIN FETCH c.member " + | ||
"JOIN FETCH c.commentGroup g " + | ||
"WHERE c.post.id = :postId " + | ||
"ORDER BY g.id ") | ||
List<Comment> findAllPostIdWithDetailsFetchOrderByCommentGroupId(@Param("postId") Long postId); | ||
|
||
@Modifying | ||
@Query(value = "update comment " | ||
+ "set comment_group = :id " | ||
+ "where comment_id = :id", nativeQuery = true) | ||
void updateByCommentGroup(@Param("id") Long id); | ||
|
||
} |
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