-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Closed
Description
This implementation here should be improved by not fetching single items at a time:
for (JdbcPet pet : pets) {
owner.addPet(pet);
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
List<Visit> visits = this.visitRepository.findByPetId(pet.getId()); // Problematic call
for (Visit visit : visits) {
pet.addVisit(visit);
}
}I'm not 100% convinced that the JDBC implementation of the pet clinic is very sensible in general. With SQL, I might be doing things a bit differently from JPA. It looks as though the whole example has been shoehorned into some pre-existing repositories.
But anyway, this one should be a no-brainer. There should be a method like:
interface VisitRepository {
Map<Integer, List<Visit>> findByPetIds(Integer... ids);
}Metadata
Metadata
Assignees
Labels
No labels