Card 05/ 07

ExampleDifficulty: Advanced1 min

A Spring Data JDBC Repository, End to End

A BookingAggregate is the aggregate root the previous card described. BookingJdbcRepository is the one repository it gets, and there's no repository written for anything inside it.

java
@Table("bookings")
record BookingAggregate(@Id Long id, String pickup) {}

interface BookingJdbcRepository extends CrudRepository<BookingAggregate, Long> {}
text
Spring Data JDBC saved aggregate with generated id: 1
count: 1
run in a container — a real Spring Data JDBC repository, working end to end

No @OneToMany, no lazy proxy, no persistence context to watch it — save() writes the aggregate in full, and findById would read it back the same way, in one round trip each.