Grokking Spring Boot
0% completed
Testing with Real Databases
Here is one SQL statement that the booking service could use when it creates the seats of an event. It inserts seat A12 and does nothing if that row already exists.
insert into seat (id, event_id, label, version) values (7012, 7, 'A12', 0) on conflict do nothing
The PostgreSQL documentation describes this clause plainly: "ON CONFLICT DO NOTHING simply avoids inserting a row as its alternative action." PostgreSQL is the database the booking service uses in production. We ran the same statement in a @DataJpaTest against H2, the in-memory database of our earlier tests. H2 refused it
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%