Hibernate shifts the developer mindset from thinking SQL into thinking object state transitions. According to Hibernate Docs entity may be in one of the following states:
- new/transient: the entity is not associated to a persistence context, be it a newly created object the database doesn’t know anything about.
- persistent: the entity is associated to a persistence context (residing in the 1st Level Cache) and there is a database row representing this entity.
- detached: the entity was previously associated to a persistence context, but the persistence context was closed, or the entity was manually evicted.
- removed: the entity was marked as removed and the persistence context will remove it from the database at flush time.
Moving an object from one state to another is done by calling the EntityManager methods such as:
Cascading allows propagating a given event from a parent to a child, also easing managing entities…
View original post 173 more words