The process of automatically updating the database (DML queries: insert/update/delete) with the changes to the persistent object when the session is flushed (@ commit) is known as automatic dirty checking.

When an object (POJO) enters persistent state

An object enters the persistent state when any one of the following happens:

How changes are persisted

Any changes to a persistent object are automatically saved to the database when the session is flushed.

Even though there is a session.flush() method available, you generally don't need to invoke it explicitly.

A session gets flushed when the transaction is committed.