80-2: Spring transaction

jk·2024년 4월 25일
0

kdt 풀스택

목록 보기
122/127



1. 트랙잭션에 대하여 설명하시오.

  • rollback



2. 아래가 rollback 하지 않는 이유는?

	@Transactional  //롤백 안함
	public void transetionTest5() throws SQLException  {
//		
		log.info("transetionTest5() 테스트");
//		
		BoardVO boardVO = new BoardVO();
		boardVO.setBcontent("트랜잭션5");
		boardVO.setBname("트랜잭션5");
		boardVO.setBtitle("트랜잭션5");		
//	
		mapper.insertBoard(boardVO);
//		
		throw new SQLException("RuntimeException for rollback");
	}
  • because the exception occured in runtime. So it was terminated after executing query.



3.게시판 구현에서 트랜잭션 처리 하시오.

	@Transactional
	@Override
	public void registerBuser(BuserVO vo) {
		log.info("registerBuser()..");
		boardMapper.insertIntoBuser(vo);
	}
	@Transactional
	@Override
	public void writePost(BoardVO vo) {
		log.info("writePost()..");
		boardMapper.insertIntoBoard(vo);
	}
	@Transactional
	@Override
	public void addComment(CommentsVO vo) {
		log.info("addComment()..");
		boardMapper.insertIntoComments(vo);
	}
	@Transactional
	@Override
	public void deletePost(int pnumber) {
		log.info("deletePost()..");
		boardMapper.deletePostFromPnumber(pnumber);
	}
	@Transactional
	@Override
	public void viewUp(int pnumber, String buid) {
		log.info("viewUp()..");
		boardMapper.insertPostview(pnumber, buid);
	}
	@Transactional
	@Override
	public void phitUp(int pnumber, int phit) {
		log.info("phitUp()..");
		boardMapper.updateBoardPhit(pnumber, phit);
	}
	@Transactional
	@Override
	public void plikeUp(int pnumber, int plike) {
		log.info("plikeUp()..");
		boardMapper.updateBoardPlike(pnumber, plike);
	}
	@Transactional
	@Override
	public void likeUp(int pnumber, String buid) {
		log.info("likeUp()..");
		boardMapper.insertPostlike(pnumber, buid);
	}



4.checked Exception 과 unchecked Exception 차이는?

  • checked during compiling or not.
profile
Brave but clumsy

0개의 댓글