Skip to content

Commit

Permalink
[MODIFY] modify trasactional attribute (readOnly)
Browse files Browse the repository at this point in the history
- for Optimize modify trascational attribute : readOnly
  • Loading branch information
himodu committed May 22, 2024
1 parent 8db29a7 commit 5ab9ac8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import LlikelionKNU.KNUfest.domain.user.repository.UserBoothRepository;
import LlikelionKNU.KNUfest.domain.user.service.UserService;
import LlikelionKNU.KNUfest.global.error.NoExistException;
import jakarta.transaction.Transactional;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,6 +32,7 @@ public class BoothServiceImpl implements BoothService{
private final UserService userService;

@Override
@Transactional(readOnly = true)
public AllBooth getAllbooth(String userHash) {

List<BoothEntity> boothes = boothrepository.findAll();
Expand Down Expand Up @@ -74,6 +76,7 @@ public AllBooth getAllbooth(String userHash) {
}

@Override
@Transactional(readOnly = true)
public BoothDetail getBooth(int boothnum, String categori, String userHash) {
Optional<BoothEntity> boothOp = boothrepository.findByBoothnumAndCategori(boothnum, categori);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import LlikelionKNU.KNUfest.domain.user.service.UserService;
import LlikelionKNU.KNUfest.global.error.NoExistException;
import LlikelionKNU.KNUfest.global.error.UserHashWrongException;
import jakarta.transaction.Transactional;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -29,6 +30,7 @@ public class CommentServiceImpl implements CommentService{


@Override
@Transactional(readOnly = true)
public List<Comment> getCommentPage(int boothNum, String categori, int page, String userHash) {

Optional<BoothEntity> boothOp = boothRepository.findByBoothnumAndCategori(boothNum, categori);
Expand Down Expand Up @@ -62,9 +64,9 @@ public List<Comment> getCommentPage(int boothNum, String categori, int page, Str
}

@Override
@Transactional
public Long postComment(int boothNum, String categori, CommentRequest commentRequest, String userHash) {


UserEntity user = userService.getUserByHash(userHash);
Optional<BoothEntity> boothOp = boothRepository.findByBoothnumAndCategori(boothNum, categori);
BoothEntity booth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import LlikelionKNU.KNUfest.domain.user.entity.UserCountEntity;
import LlikelionKNU.KNUfest.domain.user.repository.UserCountRepository;
import LlikelionKNU.KNUfest.global.error.NoExistException;
import jakarta.transaction.Transactional;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

Expand All @@ -16,6 +17,7 @@ public class UserCountServiceImpl implements UserCountService {
private final UserCountRepository userCountRepository;

@Override
@Transactional(readOnly = true)
public Long getUserCount() {

Optional<UserCountEntity> userCountEntity = userCountRepository.findById(1L);
Expand Down

0 comments on commit 5ab9ac8

Please sign in to comment.