javax.persistence
Interface EntityManager

All Known Implementing Classes:
AmberConnection, AmberEntityManager, CacheConnection, EntityManagerExtendedProxy, EntityManagerJtaProxy, EntityManagerProxy

public interface EntityManager

The main application interface to the persistence context.


Method Summary
 void clear()
          Clears the context, causing all entities to become detached.
 void close()
          Closes the entity manager.
 boolean contains(java.lang.Object entity)
          Check if the instance belongs to the current context.
 Query createNamedQuery(java.lang.String name)
          Creates a named query.
<T> TypedQuery<T>
createNamedQuery(java.lang.String name, java.lang.Class<T> resultClass)
          Creates a named query.
 Query createNativeQuery(java.lang.String sql)
          Creates a native SQL query.
 Query createNativeQuery(java.lang.String sql, java.lang.Class resultClass)
          Creates a native SQL query.
 Query createNativeQuery(java.lang.String sql, java.lang.String resultSetMapping)
          Creates a query for SQL.
<T> TypedQuery<T>
createQuery(CriteriaQuery<T> criteriaQuery)
          Creates a TypedQuery for a criteria
 Query createQuery(java.lang.String ql)
          Creates a new query.
<T> TypedQuery<T>
createQuery(java.lang.String qlString, java.lang.Class<T> resultClass)
          Creates a TypedQuery for a criteria
 void detach(java.lang.Object entity)
          Clears the entity
<T> T
find(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
          Find based on the primary key.
<T> T
find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, LockModeType lockMode)
          Find based on the primary key.
<T> T
find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
          Find based on the primary key.
<T> T
find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, java.util.Map<java.lang.String,java.lang.Object> properties)
          Find based on the primary key.
 void flush()
          Synchronize the context with the database.
 CriteriaBuilder getCriteriaBuilder()
          Returns a CriteriaBuilder to create CriteriaQuery objects.
 java.lang.Object getDelegate()
          Gets the delegate.
 EntityManagerFactory getEntityManagerFactory()
          Returns the owning factory
 FlushModeType getFlushMode()
          Returns the flush mode for the objects in the context.
 LockModeType getLockMode(java.lang.Object entity)
          Returns the lock mode for the entity
 Metamodel getMetamodel()
          Returns the Metamodel interface for the persistence unit.
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Returns the properties for the entity manager
<T> T
getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
          Gets an instance whose state may be lazily fetched.
 EntityTransaction getTransaction()
          Returns the transaction manager object.
 boolean isOpen()
          Returns true if the entity manager is open.
 void joinTransaction()
          Joins the transaction.
 void lock(java.lang.Object entity, LockModeType lockMode)
          Sets the lock mode for an entity.
 void lock(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
          Sets the lock mode for an entity.
<T> T
merge(T entity)
          Merge the state of the entity to the current context.
 void persist(java.lang.Object entity)
          Makes an object managed and persistent.
 void refresh(java.lang.Object entity)
          Update the state of the instance from the database.
 void refresh(java.lang.Object entity, LockModeType lockMode)
          Update the state of the instance from the database.
 void refresh(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
          Update the state of the instance from the database.
 void refresh(java.lang.Object entity, java.util.Map<java.lang.String,java.lang.Object> properties)
          Update the state of the instance from the database.
 void remove(java.lang.Object entity)
          Removes the instance.
 void setFlushMode(FlushModeType flushMode)
          Sets the flush mode for all objects in the context.
 void setProperty(java.lang.String propertyName, java.lang.Object value)
          Sets properties for the entity manager
<T> T
unwrap(java.lang.Class<T> cls)
          Returns the object of the type for a provider-specific API
 

Method Detail

persist

void persist(java.lang.Object entity)
Makes an object managed and persistent.


merge

<T> T merge(T entity)
Merge the state of the entity to the current context.


remove

void remove(java.lang.Object entity)
Removes the instance.


find

<T> T find(java.lang.Class<T> entityClass,
           java.lang.Object primaryKey)
Find based on the primary key.


find

<T> T find(java.lang.Class<T> entityCLass,
           java.lang.Object primaryKey,
           java.util.Map<java.lang.String,java.lang.Object> properties)
Find based on the primary key.

Since:
JPA 2.0

find

<T> T find(java.lang.Class<T> entityCLass,
           java.lang.Object primaryKey,
           LockModeType lockMode)
Find based on the primary key.

Since:
JPA 2.0

find

<T> T find(java.lang.Class<T> entityCLass,
           java.lang.Object primaryKey,
           LockModeType lockMode,
           java.util.Map<java.lang.String,java.lang.Object> properties)
Find based on the primary key.

Since:
JPA 2.0

getReference

<T> T getReference(java.lang.Class<T> entityClass,
                   java.lang.Object primaryKey)
Gets an instance whose state may be lazily fetched.


flush

void flush()
Synchronize the context with the database.


setFlushMode

void setFlushMode(FlushModeType flushMode)
Sets the flush mode for all objects in the context.


getFlushMode

FlushModeType getFlushMode()
Returns the flush mode for the objects in the context.


lock

void lock(java.lang.Object entity,
          LockModeType lockMode)
Sets the lock mode for an entity.


lock

void lock(java.lang.Object entity,
          LockModeType lockMode,
          java.util.Map<java.lang.String,java.lang.Object> properties)
Sets the lock mode for an entity.

Since:
JPA 2.0

refresh

void refresh(java.lang.Object entity)
Update the state of the instance from the database.


refresh

void refresh(java.lang.Object entity,
             java.util.Map<java.lang.String,java.lang.Object> properties)
Update the state of the instance from the database.

Since:
JPA 2.0

refresh

void refresh(java.lang.Object entity,
             LockModeType lockMode)
Update the state of the instance from the database.

Since:
JPA 2.0

refresh

void refresh(java.lang.Object entity,
             LockModeType lockMode,
             java.util.Map<java.lang.String,java.lang.Object> properties)
Update the state of the instance from the database.

Since:
JPA 2.0

clear

void clear()
Clears the context, causing all entities to become detached.


detach

void detach(java.lang.Object entity)
Clears the entity

Since:
JPA 2.0

contains

boolean contains(java.lang.Object entity)
Check if the instance belongs to the current context.


getLockMode

LockModeType getLockMode(java.lang.Object entity)
Returns the lock mode for the entity

Since:
JPA 2.0

setProperty

void setProperty(java.lang.String propertyName,
                 java.lang.Object value)
Sets properties for the entity manager

Since:
JPA 2.0

getProperties

java.util.Map<java.lang.String,java.lang.Object> getProperties()
Returns the properties for the entity manager

Since:
JPA 2.0

createQuery

Query createQuery(java.lang.String ql)
Creates a new query.


createQuery

<T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)
Creates a TypedQuery for a criteria

Since:
JPA 2.0

createQuery

<T> TypedQuery<T> createQuery(java.lang.String qlString,
                              java.lang.Class<T> resultClass)
Creates a TypedQuery for a criteria

Since:
JPA 2.0

createNamedQuery

Query createNamedQuery(java.lang.String name)
Creates a named query.


createNamedQuery

<T> TypedQuery<T> createNamedQuery(java.lang.String name,
                                   java.lang.Class<T> resultClass)
Creates a named query.

Since:
JPA 2.0

createNativeQuery

Query createNativeQuery(java.lang.String sql)
Creates a native SQL query.


createNativeQuery

Query createNativeQuery(java.lang.String sql,
                        java.lang.Class resultClass)
Creates a native SQL query.


createNativeQuery

Query createNativeQuery(java.lang.String sql,
                        java.lang.String resultSetMapping)
Creates a query for SQL.


joinTransaction

void joinTransaction()
Joins the transaction.


unwrap

<T> T unwrap(java.lang.Class<T> cls)
Returns the object of the type for a provider-specific API


getDelegate

java.lang.Object getDelegate()
Gets the delegate.


close

void close()
Closes the entity manager.


isOpen

boolean isOpen()
Returns true if the entity manager is open.


getTransaction

EntityTransaction getTransaction()
Returns the transaction manager object.


getEntityManagerFactory

EntityManagerFactory getEntityManagerFactory()
Returns the owning factory

Since:
JPA 2.0

getCriteriaBuilder

CriteriaBuilder getCriteriaBuilder()
Returns a CriteriaBuilder to create CriteriaQuery objects.

Since:
JPA 2.0

getMetamodel

Metamodel getMetamodel()
Returns the Metamodel interface for the persistence unit.

Since:
JPA 2.0