From fd4361b118931e07a7a1bde04750ec32a5fdb56e Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sat, 20 Dec 2025 22:32:00 +0100 Subject: [PATCH 1/8] Use snake case physical naming strategy Use snake case physical naming strategy to reduce the need to specify column names. Signed-off-by: Philippe Marschall --- .../samples/petclinic/model/NamedEntity.java | 2 +- .../org/springframework/samples/petclinic/model/Person.java | 4 ++-- .../org/springframework/samples/petclinic/owner/Owner.java | 6 +++--- .../org/springframework/samples/petclinic/owner/Pet.java | 2 +- src/main/resources/application.properties | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java index 7149c22ed..61e882a95 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java @@ -30,7 +30,7 @@ import jakarta.validation.constraints.NotBlank; @MappedSuperclass public class NamedEntity extends BaseEntity { - @Column(name = "name") + @Column @NotBlank private String name; diff --git a/src/main/java/org/springframework/samples/petclinic/model/Person.java b/src/main/java/org/springframework/samples/petclinic/model/Person.java index 7ee1f0397..30b5829d8 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Person.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Person.java @@ -27,11 +27,11 @@ import jakarta.validation.constraints.NotBlank; @MappedSuperclass public class Person extends BaseEntity { - @Column(name = "first_name") + @Column @NotBlank private String firstName; - @Column(name = "last_name") + @Column @NotBlank private String lastName; 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 715863cd2..480a7a690 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java @@ -48,15 +48,15 @@ import jakarta.validation.constraints.NotBlank; @Table(name = "owners") public class Owner extends Person { - @Column(name = "address") + @Column @NotBlank private String address; - @Column(name = "city") + @Column @NotBlank private String city; - @Column(name = "telephone") + @Column @NotBlank @Pattern(regexp = "\\d{10}", message = "{telephone.invalid}") private String telephone; diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Pet.java b/src/main/java/org/springframework/samples/petclinic/owner/Pet.java index 1945f9b67..4f8409ef2 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Pet.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Pet.java @@ -45,7 +45,7 @@ import jakarta.persistence.Table; @Table(name = "pets") public class Pet extends NamedEntity { - @Column(name = "birth_date") + @Column @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate birthDate; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6ed985654..630c1145a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,6 +9,7 @@ spring.thymeleaf.mode=HTML # JPA spring.jpa.hibernate.ddl-auto=none spring.jpa.open-in-view=false +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl # Internationalization spring.messages.basename=messages/messages From 2beb2380a32ad88cc1c89dbad9235189c803a830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 09:34:29 +0100 Subject: [PATCH 2/8] Remove outdated references to HSQLDB Closes gh-2165 --- src/main/resources/db/hsqldb/data.sql | 53 -------------------- src/main/resources/db/hsqldb/schema.sql | 64 ------------------------- 2 files changed, 117 deletions(-) delete mode 100644 src/main/resources/db/hsqldb/data.sql delete mode 100644 src/main/resources/db/hsqldb/schema.sql diff --git a/src/main/resources/db/hsqldb/data.sql b/src/main/resources/db/hsqldb/data.sql deleted file mode 100644 index 16dda3e84..000000000 --- a/src/main/resources/db/hsqldb/data.sql +++ /dev/null @@ -1,53 +0,0 @@ -INSERT INTO vets VALUES (1, 'James', 'Carter'); -INSERT INTO vets VALUES (2, 'Helen', 'Leary'); -INSERT INTO vets VALUES (3, 'Linda', 'Douglas'); -INSERT INTO vets VALUES (4, 'Rafael', 'Ortega'); -INSERT INTO vets VALUES (5, 'Henry', 'Stevens'); -INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins'); - -INSERT INTO specialties VALUES (1, 'radiology'); -INSERT INTO specialties VALUES (2, 'surgery'); -INSERT INTO specialties VALUES (3, 'dentistry'); - -INSERT INTO vet_specialties VALUES (2, 1); -INSERT INTO vet_specialties VALUES (3, 2); -INSERT INTO vet_specialties VALUES (3, 3); -INSERT INTO vet_specialties VALUES (4, 2); -INSERT INTO vet_specialties VALUES (5, 1); - -INSERT INTO types VALUES (1, 'cat'); -INSERT INTO types VALUES (2, 'dog'); -INSERT INTO types VALUES (3, 'lizard'); -INSERT INTO types VALUES (4, 'snake'); -INSERT INTO types VALUES (5, 'bird'); -INSERT INTO types VALUES (6, 'hamster'); - -INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); -INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); -INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); -INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); -INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); -INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); -INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); -INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); -INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); -INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); - -INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1); -INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2); -INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 3); -INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 3); -INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 4); -INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 5); -INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 6); -INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 6); -INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 7); -INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 8); -INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 9); -INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 10); -INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 10); - -INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot'); -INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot'); -INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered'); -INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed'); diff --git a/src/main/resources/db/hsqldb/schema.sql b/src/main/resources/db/hsqldb/schema.sql deleted file mode 100644 index 5d6760a4b..000000000 --- a/src/main/resources/db/hsqldb/schema.sql +++ /dev/null @@ -1,64 +0,0 @@ -DROP TABLE vet_specialties IF EXISTS; -DROP TABLE vets IF EXISTS; -DROP TABLE specialties IF EXISTS; -DROP TABLE visits IF EXISTS; -DROP TABLE pets IF EXISTS; -DROP TABLE types IF EXISTS; -DROP TABLE owners IF EXISTS; - - -CREATE TABLE vets ( - id INTEGER IDENTITY PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR(30) -); -CREATE INDEX vets_last_name ON vets (last_name); - -CREATE TABLE specialties ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(80) -); -CREATE INDEX specialties_name ON specialties (name); - -CREATE TABLE vet_specialties ( - vet_id INTEGER NOT NULL, - specialty_id INTEGER NOT NULL -); -ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id); -ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); - -CREATE TABLE types ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(80) -); -CREATE INDEX types_name ON types (name); - -CREATE TABLE owners ( - id INTEGER IDENTITY PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR_IGNORECASE(30), - address VARCHAR(255), - city VARCHAR(80), - telephone VARCHAR(20) -); -CREATE INDEX owners_last_name ON owners (last_name); - -CREATE TABLE pets ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(30), - birth_date DATE, - type_id INTEGER NOT NULL, - owner_id INTEGER -); -ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id); -ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id); -CREATE INDEX pets_name ON pets (name); - -CREATE TABLE visits ( - id INTEGER IDENTITY PRIMARY KEY, - pet_id INTEGER, - visit_date DATE, - description VARCHAR(255) -); -ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id); -CREATE INDEX visits_pet_id ON visits (pet_id); From 95f7e82ad5fd16114d4655d29196566d48d0ea9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 09:36:20 +0100 Subject: [PATCH 3/8] Upgrade to Spring Boot 4.0.1 --- build.gradle | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index e7540a9f5..f3da79125 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'checkstyle' - id 'org.springframework.boot' version '4.0.0' + id 'org.springframework.boot' version '4.0.1' id 'io.spring.dependency-management' version '1.1.7' id 'org.graalvm.buildtools.native' version '0.11.1' id 'org.cyclonedx.bom' version '3.0.2' diff --git a/pom.xml b/pom.xml index ae930ae5c..fb38cc3db 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 4.0.0 + 4.0.1 org.springframework.samples spring-petclinic From 8f5f58cb01260806700aa71b3d1d3bbe4c8344d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 09:36:54 +0100 Subject: [PATCH 4/8] Upgrade to Apache Maven 3.9.12 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index c0bcafe98..8dea6c227 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,3 +1,3 @@ wrapperVersion=3.3.4 distributionType=only-script -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip From 5149abbc90a6710fdb5e8aa0d0530b093e4a80cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 09:37:38 +0100 Subject: [PATCH 5/8] Upgrade to native buildtools 0.11.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f3da79125..936ff1edb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'checkstyle' id 'org.springframework.boot' version '4.0.1' id 'io.spring.dependency-management' version '1.1.7' - id 'org.graalvm.buildtools.native' version '0.11.1' + id 'org.graalvm.buildtools.native' version '0.11.3' id 'org.cyclonedx.bom' version '3.0.2' id 'io.spring.javaformat' version '0.0.47' id "io.spring.nohttp" version "0.0.11" From 987613eb4958f25ec3b137fd860cf915f516f0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 09:40:11 +0100 Subject: [PATCH 6/8] Polish --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1c65baff..95618d59f 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ The following items should be installed in your system: - Java 25 or newer (full JDK, not a JRE) - [Git command line tool](https://help.github.com/articles/set-up-git) - Your preferred IDE - - Eclipse with the m2e plugin. Note: when m2e is available, there is an m2 icon in `Help -> About` dialog. If m2e is - not there, follow the install process [here](https://www.eclipse.org/m2e/) + - Eclipse with the m2e plugin. Note: when m2e is available, there is a m2 icon in `Help -> About` dialog. If m2e is + not there, follow the installation process [here](https://www.eclipse.org/m2e/) - [Spring Tools Suite](https://spring.io/tools) (STS) - [IntelliJ IDEA](https://www.jetbrains.com/idea/) - [VS Code](https://code.visualstudio.com) From 430b5ff41d2d477c62a3890c33e716f4a1b3062e Mon Sep 17 00:00:00 2001 From: anirudhasht Date: Thu, 1 Jan 2026 16:54:45 +0530 Subject: [PATCH 7/8] Fix Java version mismatch and clarify Gradle usage in readme See gh-2188 Signed-off-by: anirudhasht --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95618d59f..5b8eb036b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,15 @@ Or you can run it from Maven directly using the Spring Boot Maven plugin. If you ./mvnw spring-boot:run ``` + > NOTE: If you prefer to use Gradle, you can build the app using `./gradlew build` and look for the jar file in `build/libs`. +> +> You can also run the application directly using Gradle: +> +> ```bash +> ./gradlew bootRun +> ``` + ## Building a Container @@ -98,7 +106,7 @@ There is a `petclinic.css` in `src/main/resources/static/resources/css`. It was The following items should be installed in your system: -- Java 25 or newer (full JDK, not a JRE) +- Java 17 or newer (LTS recommended, full JDK required) - [Git command line tool](https://help.github.com/articles/set-up-git) - Your preferred IDE - Eclipse with the m2e plugin. Note: when m2e is available, there is a m2 icon in `Help -> About` dialog. If m2e is From f5b8a8945194f271384dd7132f4be03d984c42e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Fri, 2 Jan 2026 08:11:31 +0100 Subject: [PATCH 8/8] Polish "Fix Java version mismatch and clarify Gradle usage in readme" See gh-2188 --- README.md | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 5b8eb036b..e8aa6f3d8 100644 --- a/README.md +++ b/README.md @@ -14,36 +14,31 @@ See the presentation here: ## Run Petclinic locally Spring Petclinic is a [Spring Boot](https://spring.io/guides/gs/spring-boot) application built using [Maven](https://spring.io/guides/gs/maven/) or [Gradle](https://spring.io/guides/gs/gradle/). -Java 17 or later is required for the build, and the application can run with Java 17 or newer: +Java 17 or later is required for the build, and the application can run with Java 17 or newer. + +You first need to clone the project locally: ```bash git clone https://github.com/spring-projects/spring-petclinic.git cd spring-petclinic -./mvnw package -java -jar target/*.jar ``` +If you are using Maven, you can start the application on the command-line as follows: -(On Windows, or if your shell doesn't expand the glob, you might need to specify the JAR file name explicitly on the command line at the end there.) +```bash +./mvnw spring-boot:run +``` +With Gradle, the command is as follows: + +```bash +./gradlew bootRun +``` You can then access the Petclinic at . petclinic-screenshot -Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this, it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this): - -```bash -./mvnw spring-boot:run -``` - - -> NOTE: If you prefer to use Gradle, you can build the app using `./gradlew build` and look for the jar file in `build/libs`. -> -> You can also run the application directly using Gradle: -> -> ```bash -> ./gradlew bootRun -> ``` - +You can, of course, run Petclinic in your favorite IDE. +See below for more details. ## Building a Container @@ -106,7 +101,7 @@ There is a `petclinic.css` in `src/main/resources/static/resources/css`. It was The following items should be installed in your system: -- Java 17 or newer (LTS recommended, full JDK required) +- Java 17 or newer (full JDK, not a JRE) - [Git command line tool](https://help.github.com/articles/set-up-git) - Your preferred IDE - Eclipse with the m2e plugin. Note: when m2e is available, there is a m2 icon in `Help -> About` dialog. If m2e is