AcademyService { @Transactional(readOnly = true) public List<String> findAllSubjectNamesByJoinFetch(){ return extractSubjectNames(academyRepository.findAllJoinFetch()); } 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여러개를_joinFetch로_가져온다() throws Exception { List<Academy> academies = academyRepository.findAllJoinFetch(); List<String> subjectNames = academyService.findAllSubjectNamesByJoinFetch(); assertThat(academies.size(), is(20)); assertThat(subjectNames.size(), is(20)); }