글 삭제 - deleteById()
페이지 정보
작성자 관리자 작성일 24-06-15 14:21 조회 968 댓글 0본문
package web.repository;
import java.util.Optional;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import jakarta.transaction.Transactional;
import lombok.extern.log4j.Log4j2;
import web.domain.Board;
@SpringBootTest
@Log4j2
public class BoardRepositoryTest {
@Autowired
private BoardRepository boardRepository;
//글 삭제
@Test
public void testDelete() {
Long bno = 101L;
boardRepository.deleteById(bno);
}
}
[설명]
deleteById() : 데이타베이스 내부에 같은 @Id가 존재하는지 확인 후 delete 문이 실행된다.
[콘솔창 확인내용]
Hibernate:
select
b1_0.bno,
b1_0.content,
b1_0.moddate,
b1_0.regdate,
b1_0.title,
b1_0.writer
from
board b1_0
where
b1_0.bno=?
Hibernate:
delete
from
board
where
bno=?
댓글목록 0
등록된 댓글이 없습니다.