jpa spec jsr 317
open jpa manual
In an applicationserver, EntityManager instances are typically injected, rendering the EntityManagerFactory unnecessary.
- Persistence : contains static helper methods to obtain EntityManagerFactory
instances in a vendor-neutral fashion.
- EntityManagerFactory: is a factory for Entity-Manager
- EntityManager: is the primary JPA interface used by applications.Each EntityManager manages a set of persistent objects, and has APIs to insert new objects and delete existing ones. EntityManagers also act as factories for Query instances.
- Entity: persistent objects that represent datastore records.
- Query: Query interface is implemented by each JPA vendor to find persistent objects that
meet certain criteria. JPA standardizes support for queries using both the Java Persistence Query Language (JPQL) and the Structured Query Language (SQL). You obtain Query instances from an EntityManager.
JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same record, it throws an exception to the transaction attempting to commit last. This prevents overwriting the previous commit with stale data.
private int version;
JPA introduces another form of object identity, called entity identity or persistent identity. Entity identity tests whether two persistent objects represent the same state in the datastore.