The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →JPA can persist changes to an entity without a separate update call—but only while that entity is managed by a persistence context. JPA detects changes to managed state, then synchronizes them with the database during a flush. A setter call alone does not guarantee an immediate SQL update or a committed transaction.
Why a separate update call is often unnecessary
When an entity is associated with an active persistence context, JPA monitors its persistent fields or properties. Change one of them, and the provider can detect that the managed entity is dirty and schedule the modification for synchronization. The Jakarta Persistence EntityManager API describes this automatic detection and notes that there is no explicit update operation for this purpose.
As an Amazon Associate I earn from qualifying purchases.
That is the source of the apparent “silent save”: your Java object changes first, and JPA can later translate the changed state into database work. The object’s in-memory state and the database’s state are not necessarily updated at the same moment.
Dirty checking and flush are separate stages
1. Change the managed object
After you load or persist an entity through an EntityManager, it is managed while it remains associated with that persistence context. Modifying a persistent property changes the in-memory entity. You generally do not need to call an update method for that already-managed instance.
#1 Best Overall
2. Synchronize pending changes
Flush is the process that synchronizes pending persistence-context changes with the database. The provider may issue SQL updates during this step. You can request synchronization explicitly with EntityManager.flush(), or the provider may flush at a time required by the flush mode or transaction lifecycle.
Flush is not the same as commit. A flush can send SQL while the transaction remains open; transaction commit is what completes the transaction. A later database or constraint error can still cause the transaction to fail.
When JPA flushes changes
The timing depends on the flush mode, queries, and transaction completion. Jakarta Persistence 3.2 defines AUTO and COMMIT behavior:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems| Flush mode | What JPA requires | What to keep in mind |
|---|---|---|
| AUTO | The provider must ensure that changes which could affect a query are visible when that query is processed. It may flush before executing the query. | Pending changes are flushed at transaction commit. The exact query-by-query schedule can depend on the provider. |
| COMMIT | Flushing occurs at transaction commit, though the provider may flush earlier. | The effect of unflushed changes on query results is unspecified by JPA 3.2. |
The Jakarta Persistence 3.2 specification defines these modes. The 4.0 nightly API also lists EXPLICIT, where each flush must be requested with EntityManager.flush(). Because that API is a nightly version, do not assume EXPLICIT is available in older JPA versions.
Hibernate’s AUTO scheduling
Hibernate’s stable user guide describes its AUTO mode as flushing before transaction commit, before JPQL/HQL queries that overlap queued entity actions, and before native SQL queries without registered synchronization. Its COMMIT mode aims to defer flushing until commit but may flush earlier. These are Hibernate-specific details, not a universal schedule promised by JPA. See the Hibernate ORM user guide.
What must be true for automatic detection to work
The entity must be managed
Automatic dirty checking applies to an entity associated with the persistence context. If an entity is detached, changing its Java fields alone does not make those changes part of the context’s pending work. The application must arrange for the entity’s state to be merged or otherwise managed.
Rank #4
A transaction must be active and joined
JPA does not permit the provider to flush when no transaction is active or when the persistence context has not joined the transaction. With an application-managed context created outside a transaction, whether and when it joins can depend on how the context is managed. The JPA 3.2 specification and 4.0 nightly API describe these transaction constraints.
The owning side of a relationship must be updated
For a bidirectional association, update the owning side—the side that controls the relationship mapping. Changing only the inverse side may leave the database relationship unchanged. The JPA specification explains the owning-side rule.
Best Value
A practical way to reason about a “silent save”
- Managed entity changed: JPA can detect the modified persistent state without a separate update call.
- Flush has not happened: The Java object may show the new value while the database has not yet been synchronized.
- Flush happens: The provider synchronizes pending changes, subject to an active transaction joined by the persistence context.
- Transaction commits: The transaction completes; a successful flush alone does not establish that commit has succeeded.
This explanation concerns ordinary changes to managed entities. Bulk JPQL and native update operations have different considerations and are not covered by the ordinary dirty-checking model described here.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




