intermediateJPA & Hibernate460 of 469
save() vs saveAndFlush().
Tests whether you know save() just schedules the write in Hibernate's session (flushed later, typically at transaction commit or the next query), while saveAndFlush() forces the write to the DB immediately -- useful when you need the generated ID or DB-side effects right away within the same transaction.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a responseNext Step
←PreviousContinue to Hibernate second-level cache with two app instances: why does instance B serve stale data?→
← Back to all Spring Boot & Microservices questions