AcademyService { @Transactional(readOnly = true) public List<String> findAllSubjectNames(){ return extractSubjectNames(academyRepository.findAll()); } AcademyService(AcademyRepository academyRepository); @Transactional(readOnly = true) List<String> findAllSubjectNames(); @Transactional(readOnly = true) List<String> findAllSubjectNamesByJoinFetch(); @Transactional(readOnly = true) List<String> findAllSubjectNamesByEntityGraph(); @Transactional(readOnly = true) List<String> findAllSubjectNamesByJoinFetchDistinct(); @Transactional(readOnly = true) List<String> findAllSubjectNamesByEntityGraphDistinct();  }
@Test public void Academy여러개를_조회시_Subject가_N1_쿼리가발생한다() throws Exception { List<String> subjectNames = academyService.findAllSubjectNames(); assertThat(subjectNames.size(), is(10)); }