Skip to content

Commit

Permalink
feat(blog): apply readonly trasaction on get methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wwingyou committed Nov 16, 2024
1 parent 960f5a8 commit 850963f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -127,6 +128,7 @@ public void deletePost(Long postId, String writerStudentNumber) {
}

@Override
@Transactional(readOnly = true)
public Page<PostOverview> getPostOverviews(PostQuery query, String userStudentNumber, Pageable pageable) {
User user = getUserEntity(userStudentNumber);
Specification<Post> spec = PostSpecifications.hasTitleLike(query.getKeyword())
Expand All @@ -149,6 +151,7 @@ public Page<PostOverview> getPostOverviews(PostQuery query, String userStudentNu
}

@Override
@Transactional(readOnly = true)
public PostOverview getPostOverview(Long postId, String userStudentNumber) {
Post post = getPostEntity(postId);
User user = getUserEntity(userStudentNumber);
Expand Down Expand Up @@ -203,6 +206,7 @@ public void deleteComment(Long postId, Long commentId, String writerStudentNumbe
}

@Override
@Transactional(readOnly = true)
public Page<CommentView> getComments(Long postId, Pageable pageable) {
Post post = postRepository.findById(postId)
.orElseThrow(PostNotFoundException::new);
Expand Down Expand Up @@ -262,6 +266,7 @@ public void deleteReply(Long postId, Long commentId, Long replyId, String writer
}

@Override
@Transactional(readOnly = true)
public Page<ReplyView> getReplies(Long postId, Long commentId, Pageable pageable) {
Comment comment = commentRepository.findById(commentId)
.orElseThrow(CommentNotFoundException::new);
Expand Down

0 comments on commit 850963f

Please sign in to comment.