`EntityManager.persist()` moves a new entity instance from transient to persistent state. The instance becomes managed by the current persistence context and is scheduled to have a database representation. Calling `persist()` does not necessarily execute an SQL `INSERT` immediately. section 10.1.1 section 10.2.2
Save a new entity
Create and initialize an entity, then make it persistent: Item item = new Item(); item.setName("Some Item"); em.persist(item); Long itemId = item.getId(); Hibernate normally flushes the context and executes the `INSERT` when the transaction commits; it may batch that statement with others. An identifier generator that requires an insert can instead cause the `INSERT` during `persist()`. Do not assume the identifier is available before flushing in every configuration. section 10.2.2
The same operation has two other useful roles:
- Undo a pending removal: call `persist()` on a removed instance before the persistence context is flushed to make it persistent again and cancel its deletion. section 10.2.5
- Persist through an association: with `CascadeType.PERSIST` enabled, adding new billing details to an already-persistent user makes the added instances persistent. section 10.1.1 section 13.1.3
With an unsynchronized persistence context and a pre-insert identifier generator, `persist()` can assign an identifier while leaving the `INSERT` queued. Join the context to a transaction when ready to write; synchronization and flushing occur at commit. section 11.3.2
