② BoardRepositoryTest ( read )
페이지 정보
본문
package web.repository;
import java.util.Optional;
import java.util.UUID;
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 org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import jakarta.transaction.Transactional;
import lombok.extern.log4j.Log4j2;
import web.domain.Board;
import web.domain.BoardImage;
import web.dto.BoardListReplyCountDTO;
@SpringBootTest
@Log4j2
public class BoardRepositoryTest {
@Autowired
private BoardRepository boardRepository;
@Test
//@Transactional //Board 에서 fetch = FetchType.LAZY 일 경우 추가
public void testReadWithImages() {
//Optional<Board> result = boardRepository.findById(1L); //존재하는 bno 값 매칭
Optional<Board> result = boardRepository.findByIdWithImages(1L);
Board board= result.orElseThrow();
log.info(board);
log.info("=======================");
for(BoardImage boardImage : board.getImageSet()) { //첨부 이미지 목록
log.info(boardImage);
}
}
...
...
...
}
- 이전글BoardRepository ( 내용 추가 ) 24.06.28
- 다음글③ BoardRepositoryTest ( modify ) 24.06.28
댓글목록
등록된 댓글이 없습니다.