인프런 커뮤니티 질문&답변
@Trasacntion 롤백 관련 질문있습니다.!
해결된 질문
작성
·
160
0
안녕하세요 ~ 강사님.
JPA는 트랜잭션 단위에서 RuntimeException이 발생하면 롤백을 진행한다고 배웠는데요~ 실습중에 예외 케이스를 발견해서 질문 드립니다.!!
@SpringBootTest
@Transactional
@Rollback(value = false)
class HumanTest {
@Autowired
HumanRepository humanRepository;
@Autowired
EntityManager em;
@BeforeEach
void setup() {
Human human = new Human();
human.setName("human");
humanRepository.save(human);
}
@Test
void t1() {
List<Human> all = humanRepository.findAll();
Human human = all.get(0);
human.setName("person");
throw new IllegalArgumentException(); // rollback
}
}
테스트에서 분명 예외가 발생했기 때문에 db에 human을 조회하면 name이 `human`이 나올거라 예상했는데, person이 나오더라고요..!!
이거 관련해서 답변을 얻을 수 있을까요?
좋은 강의 항상 감사합니다.






아 그렇군요!! 답변 감사합니다!!!