From 2873e55738ec64dd17ca8759e145a70a4a06272c Mon Sep 17 00:00:00 2001 From: YiXuan Ding <1328032567@qq.com> Date: Tue, 5 Nov 2024 23:46:15 +0800 Subject: [PATCH] : revert the logic. --- .../springframework/samples/petclinic/owner/PetController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java index b58c1ba0059..6c37f057d17 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java @@ -138,7 +138,7 @@ public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owne // checking if the pet name already exist for the owner if (StringUtils.hasText(petName)) { Pet existingPet = owner.getPet(petName.toLowerCase(), false); - if (existingPet != null && existingPet.getId().equals(pet.getId())) { + if (existingPet != null && !existingPet.getId().equals(pet.getId())) { result.rejectValue("name", "duplicate", "already exists"); } }