Grokking Spring Boot
0% completed
JPA Entities and the Persistence Context
The code below moves the start of the Evening Concert 30 minutes later. It loads the event, changes one field, and ends. It never calls save, update, or any other write method.
tx.executeWithoutResult(status -> { Event evening = em.find(Event.class, eventId); evening.setStartsAt(evening.getStartsAt().plusMinutes(30)); System.out.println("changed startsAt, no save call; leaving transaction"); });
With SQL logging switched on, the run printed this.
Hibernate: select e1_0.id,e1_0.starts_at,e1_0.title,v1_0.id,v1_0.name,v1_0.rows,v1_0
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%