What is Persistence Context?

前端 未结 9 1830
难免孤独
难免孤独 2020-12-07 08:19

I am new to the Java world and JPA. I was studying JPA and came across many new terms like Entity, persistence. While reading, I could not understand the exact definition fo

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 08:37

    1. Entities are managed by javax.persistence.EntityManager instance using persistence context.
    2. Each EntityManager instance is associated with a persistence context.
    3. Within the persistence context, the entity instances and their lifecycle are managed.
    4. Persistence context defines a scope under which particular entity instances are created, persisted, and removed.
    5. A persistence context is like a cache which contains a set of persistent entities , So once the transaction is finished, all persistent objects are detached from the EntityManager's persistence context and are no longer managed.

提交回复
热议问题