From 0f2eccc384abdc012c0c6f805505e31f5374f02d Mon Sep 17 00:00:00 2001 From: "kaihang.xkh" Date: Fri, 28 Mar 2025 15:07:48 +0800 Subject: [PATCH] Add petName field for form binding --- .../samples/petclinic/owner/Owner.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java index 675b2140e..006caafd7 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java @@ -65,6 +65,13 @@ public class Owner extends Person { @OrderBy("name") private final List pets = new ArrayList<>(); + /** + * This field is used for form binding for pet search + * and is not persisted to the database. + */ + @jakarta.persistence.Transient + private String petName; + public String getAddress() { return this.address; } @@ -172,4 +179,12 @@ public class Owner extends Person { pet.addVisit(visit); } -} + public String getPetName() { + return this.petName; + } + + public void setPetName(String petName) { + this.petName = petName; + } + +} \ No newline at end of file