intermediateJPA & Hibernate Internals253 of 469
persist() vs merge()
Tests whether you know persist() only works on a transient entity and makes it managed in place, while merge() copies state from a detached entity onto a (possibly newly loaded) managed instance and returns that managed copy -- so the original reference you passed in is never the one you should keep using.
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 Explain what happens internally when a request reaches a Spring Boot application (Controller, Service, Repository, Hibernate, JDBC, database)→
← Back to all Spring Boot & Microservices questions