public interface EntityManager

Interface used to interact with the persistence context.

An EntityManager instance is associated with a persistence context. 
A persistence context is a set of entity instances 
in which for any persistent entity identity there is a unique entity instance. 
Within the persistence context, 
the entity instances and their lifecycle are managed. 
The EntityManager API is used to create and remove persistent entity instances, 
to find entities by their primary key, 
and to query over entities.

The set of entities that can be managed 
by a given EntityManager instance is defined by a persistence unit. 
A persistence unit defines the set of all classes that 
are related or grouped by the application, 
and which must be colocated in their mapping to a single database.

persistence context 에 접근하기 위한 인터페이스이다.

EntityManager 는 persistence context 와 연관이 있다. persistence context 는 entity 인스턴스들의 집합이다. persistence context 는 entity 인스턴스와 그들의 생명주기를 관리한다.

EntityManager API 는 entity 인스턴스를 생성 또는 제거하기 위해 사용된다. 그들의 기본키로 entity 들을 찾는다.

Untitled

주요 메서드

public void persist(Object entity);

public <T> T merge(T entity);

public void remove(Object entity);

public <T> T find(Class<T> entityClass, Object primaryKey);

find()

public <T> T getReference(Class<T> entityClass, Object primaryKey);

getReference()