Hibernate shifts the developer mindset from SQL statements to entity state transitions. Once an entity is actively managed by Hibernate, all changes are going to be automatically propagated to the database.

Manipulating domain model entities (along with their associations) is much easier than writing and maintaining SQL statements. Without an ORM tool, adding a new column requires modifying all associated INSERT/UPDATE statements.

The Entity States

JPA/Hibernate monitors currently attached entities. Here are all entity states:

Entity State Transitions

To change the JPA entity state, we need to use one of the following EntityManager methods:

While Hibernate Session interface extends the JPA EntityManager, it also provides several specific methods that can be used to change the entity state:

Other