From 850963f718a7328fe51f5caa392f01e26ad5abb6 Mon Sep 17 00:00:00 2001 From: wingyou Date: Sat, 16 Nov 2024 09:30:13 +0900 Subject: [PATCH] feat(blog): apply readonly trasaction on get methods --- .../java/kr/tgwing/tech/blog/service/PostServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/kr/tgwing/tech/blog/service/PostServiceImpl.java b/src/main/java/kr/tgwing/tech/blog/service/PostServiceImpl.java index b0a6ab8..45b7ee3 100644 --- a/src/main/java/kr/tgwing/tech/blog/service/PostServiceImpl.java +++ b/src/main/java/kr/tgwing/tech/blog/service/PostServiceImpl.java @@ -52,6 +52,7 @@ public class PostServiceImpl implements PostService { private final LikeHistoryRepository likeHistoryRepository; @Override + @Transactional(readOnly = true) public PostDetail getPost(Long postId, String userStudentNumber) { User user = getUserEntity(userStudentNumber); Post post = getPostEntity(postId); @@ -127,6 +128,7 @@ public void deletePost(Long postId, String writerStudentNumber) { } @Override + @Transactional(readOnly = true) public Page getPostOverviews(PostQuery query, String userStudentNumber, Pageable pageable) { User user = getUserEntity(userStudentNumber); Specification spec = PostSpecifications.hasTitleLike(query.getKeyword()) @@ -149,6 +151,7 @@ public Page getPostOverviews(PostQuery query, String userStudentNu } @Override + @Transactional(readOnly = true) public PostOverview getPostOverview(Long postId, String userStudentNumber) { Post post = getPostEntity(postId); User user = getUserEntity(userStudentNumber); @@ -203,6 +206,7 @@ public void deleteComment(Long postId, Long commentId, String writerStudentNumbe } @Override + @Transactional(readOnly = true) public Page getComments(Long postId, Pageable pageable) { Post post = postRepository.findById(postId) .orElseThrow(PostNotFoundException::new); @@ -262,6 +266,7 @@ public void deleteReply(Long postId, Long commentId, Long replyId, String writer } @Override + @Transactional(readOnly = true) public Page getReplies(Long postId, Long commentId, Pageable pageable) { Comment comment = commentRepository.findById(commentId) .orElseThrow(CommentNotFoundException::new);