Visit booking in Spring PetClinic ends with a call to save the owner. Hibernate merges the owner and cascades persistence through its pets and their visits. Replacing JPA means deciding which parts of that behavior the new SQL needs to preserve.

I gave a coding agent a PetClinic checkout at a fixed revision and a migration skill. Its first patch passed all 17 packaged checks, which drive the application over real HTTP and inspect committed rows in H2. Independent code review then found two bugs in the owner repository, both outside the paths those checks exercised.

Keep the migration boundary small

The agent moved owner, pet, and visit persistence from JPA to CoilBase and Jdbi. Spring Boot still managed the datasource and schema initialization, Spring MVC still handled the routes and validation, and Thymeleaf still rendered the views. The vet repositories continued to use JPA. The trial started from a specific upstream commit. The earlier full PetClinic rewrite was outside the agent’s trial inputs.

The skill asked the agent to trace requests through to committed rows and check the APIs against the selected versions. The migration used CoilBase Core 0.1.0-preview5 and Jdbi 3.55.0.

Make the visit write explicit

Upstream, the controller checks that the pet belongs to the owner in the URL, adds the validated visit to the object graph, and saves the owner. In the migration, the controller still validates the form and redirects to the owner page. A booking service now owns the CoilBase transaction, and the repository inserts the visit only if the pet matches both route IDs.

insert into visits (pet_id, visit_date, description)
select id, :date, :description
from pets
where id = :pet and owner_id = :owner

The repository checks that exactly one row was inserted. The SQL predicate enforces ownership at the write boundary even if the controller’s earlier lookup is stale. Reads reconstruct the owner’s pets and visits for the same views. Visit history sorts by date, with an ID tie-breaker for equal dates where upstream left the order unspecified.

The booking service and SQL repository share a CoilBase context over the Spring-managed datasource. The vet repositories keep their JPA transaction manager. The two transaction systems operate independently even though they use the same datasource.

Check what actually committed

The harness submitted real HTTP forms and queried H2 through a separate connection. It checked successful bookings and rejected writes, submitted visits in reverse date order to verify the displayed order, sent competing duplicate-pet requests, and restarted each application against its own persisted database.

To exercise rollback, an H2 trigger observed the inserted visit and attempted a second write that violated a foreign key. The request failed, an independent connection found no committed visit, and the next valid booking succeeded. A separate migration test let a booking statement succeed inside an outer CoilBase transaction, then failed a later statement and confirmed that the booking rolled back.

Upstream, the initial migration, and the reviewed migration each passed the same 17 packaged checks. Maven reported 79, 80, and 82 tests respectively, with two skips and zero failures or errors in each build.

Two bugs the checks missed

  1. A zero-row update looked successful. If an owner was deleted after lookup, the SQL UPDATE could affect zero rows and the controller would still report success. The fix raises an optimistic locking failure when the update finds no row.
  2. Owner search ignored the requested sort. The repository accepted a Spring Data Pageable but ignored its Sort. The search controller passed an unsorted request, so the packaged journey exercised no caller-supplied ordering. The fix maps supported sort properties to fixed SQL columns and applies the ordering before pagination.

Each fix added a regression test. The original patch and run output were preserved separately, so the 82-test result belongs to the reviewed version.

Which migration skill to use

PVR Labs publishes two skills for different migration boundaries.

A second trial on the same PetClinic revision went further. The agent migrated all three Spring Data JPA repository groups, including vets, then replaced Spring Boot and Spring MVC with Jex. The Jex application reused those SQL repositories unchanged and passed 28 Maven tests and the packaged checks. The published record notes that its owner and vet pagination still ignores caller-supplied sorting, which the exercised controllers did not request.

Review the contract as well as the journey

Both trials were verified on H2 only. PostgreSQL and MySQL were outside their scope. There was no controlled run with an agent working without the skill, so the result cannot establish whether the skill improved coding quality.

When reviewing a persistence migration, trace what callers can ask a repository to do and how it reports failure. Here, checking the affected row count and tracing the sort argument exposed gaps that successful HTTP journeys left open. Passing tests are not a complete migration contract, and independent review remains essential.