BookQueryRepository { @Transactional(readOnly = true) public Boolean exist(Long bookId) { Integer fetchOne = queryFactory .selectOne() .from(book) .where(book.id.eq(bookId)) .fetchFirst(); return fetchOne > 0; }  @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) Book getBookById(Long bookId); @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) String getBookNameById(Long bookId); @Transactional(readOnly = true) Boolean exist(Long bookId); List<BookPageDto> getBookPage(int bookNo, int pageNo);  }
@Test void test_jpaRepository_exist2() throws Exception { Long bookId = bookRepository.save(Book.builder() .name("a") .build()) .getId(); boolean exist = bookRepository.exist(bookId); assertThat(exist).isTrue(); }
@Test void test_querydsl_exist() throws Exception { Long bookId = bookRepository.save(Book.builder() .name("a") .build()) .getId(); Boolean exist = bookQueryRepository.exist(bookId); assertThat(exist).isTrue(); }