Card 02/ 07
All 7 cards
ExampleDifficulty: Intermediate1 min
Two Writes, Committed Together
bookTrip makes two separate save() calls. Both land in the database together, because @Transactional treats the whole method as one unit — this is the ordinary, working case the next two cards are both about breaking.
@Transactional
void bookTrip() {
repo.save(new TripEntity("booked"));
repo.save(new TripEntity("booked"));
}both rows committed together, count = 2Nothing about either individual save() call commits anything on its own — the transaction the method opened is what actually commits, once, after both writes have succeeded.