javax.persistence
Interface EntityManager

All Known Implementing Classes:
AmberEntityManager, EntityManagerExtendedProxy, EntityManagerProxy, EntityManagerTransactionProxy

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 clear(java.lang.Object entity)
          Clears the entity
 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.
 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.
 Query createQuery(java.lang.String ql)
          Creates a new query.
<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 properties)
          Find based on the primary key.
 void flush()
          Synchronize the context with the database.
 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
 java.util.Map 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.
 java.util.Set<java.lang.String> getSupportedProperties()
          Returns the supported properties for the entity manager
 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 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 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.
 

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,
           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 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 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,
             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 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.


clear

void clear(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

getProperties

java.util.Map getProperties()
Returns the properties for the entity manager

Since:
JPA 2.0

getSupportedProperties

java.util.Set<java.lang.String> getSupportedProperties()
Returns the supported properties for the entity manager

Since:
JPA 2.0

createQuery

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


createNamedQuery

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


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.


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