Skip to content

Commit 0db64ab

Browse files
authored
fixed (#104)
2 parents b5a328c + 780155b commit 0db64ab

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public String initCreationForm(Map<String, Object> model) {
9393
Owner owner = new Owner();
9494
validator.ValidateOwnerWithExternalService(owner);
9595
model.put("owner", owner);
96-
var petCount = ownerRepository.countPets();
96+
var petCount = ownerRepository.countPets(owner.getId());
9797
var totalVists = owner.getPets().stream().mapToLong(pet-> pet.getVisits().size())
9898
.sum();
9999
var averageCisits = totalVists/petCount;

src/main/java/org/springframework/samples/petclinic/owner/OwnerRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public interface OwnerRepository extends Repository<Owner, Integer> {
7474

7575
@Query("SELECT SIZE(o.pets) FROM Owner o WHERE o.id = :id")
7676
@Transactional(readOnly = true)
77-
int countPets();
77+
int countPets(int id);
7878

7979
/**
8080
* Returns all the owners from data store

0 commit comments

Comments
 (0)