Hibernate 1# - entity states overview
Hibernate is the most common choice when it comes to the ORM libraries used in Java backend projects. Being an ORM library Hibernate uses entities rather than SQL statements to manage database changes. In this article we will have a look at all the possible states of entities. This knowledge will give you awareness of what actions will Hibernate perform depending on the entity state. Our examples will be based on a simple Spring project. Manipulating entity states While using ORM libraries we trigger database changes by manipulating entities states. Entity class represents database table and entity instance represents row inside this table. There are two different interfaces which can be used to handle entity state transitions: EntityManager Session Both enable us to manipulate Persistence Context . Persistence Context is responsible for handling entity states. The difference is that EntityManager is the JPA specification implementation while...