public class EntityManagerImpl extends Object implements EntityManagerLite, UserTransactionSupport
| Constructor and Description |
|---|
EntityManagerImpl(com.j256.ormlite.support.ConnectionSource connectionSource,
PersistenceConfig persistenceConfig)
Create ClassyEntityManager object
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the persistence context, causing all managed
entities to become detached.
|
void |
close()
DO NOT CALL close() as the container will do this automatically.
|
boolean |
contains(Object entity)
Check if the instance belongs to the current persistence
context.
|
javax.persistence.Query |
createNamedQuery(String name)
Create an instance of Query for executing a
named query (executed using OrmLite QueryBuilder or in native SQL).
|
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find by primary key.
|
void |
flush()
Synchronize the persistence context to the underlying database.
|
Object |
getDelegate()
Returns EntityManagerDelegate object which provides access to OrmLite DAOs.
|
javax.persistence.FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained
in the persistence context.
|
<T> T |
getReference(Class<T> entityClass,
Object primaryKey)
Javax PersistenceUnitAdmin: "Get an instance, whose state may be lazily fetched".
|
javax.persistence.EntityTransaction |
getTransaction()
Returns the resource-level transaction object, if User Transactions selected, otherwise proxy object returned for which only setRollbackOnly() is active.
|
boolean |
isOpen()
Determine whether the entity manager is open.
|
void |
joinTransaction()
NOT SUPPORTED
Indicate to the EntityManager that a JTA transaction is
active.
|
void |
lock(Object entity,
javax.persistence.LockModeType lockMode)
NOT SUPPORTED.
|
<T> T |
merge(T entity)
Merge the state of the given entity into the
current persistence context.
|
void |
persist(Object entity)
Make an entity instance managed and persistent.
|
void |
refresh(Object entity)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any.
|
void |
remove(Object entity)
Remove the entity instance.
|
void |
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained
in the persistence context.
|
void |
setUserTransaction(boolean value)
setUserTransaction
Determines if getTransaction() returns null (false) or entityTransaction (true)
|
public EntityManagerImpl(com.j256.ormlite.support.ConnectionSource connectionSource,
PersistenceConfig persistenceConfig)
connectionSource - Source of all database connectionspersistenceConfig - PersistenceUnitAdmin Unit configurationpublic void setUserTransaction(boolean value)
setUserTransaction in interface UserTransactionSupportvalue - booleanpublic void persist(Object entity)
persist in interface EntityManagerLiteentity - The entity instanceIllegalArgumentException - if not an entityIllegalStateException - if this EntityManager has been closed.public <T> T merge(T entity)
merge in interface EntityManagerLiteT - the object type of the entityentity - The entity instanceIllegalArgumentException - if instance is not an entity or is a removed entityIllegalStateException - if this EntityManager has been closed.public void refresh(Object entity)
refresh in interface EntityManagerLiteentity - The entity instanceIllegalArgumentException - if not an entity or entity is not managedIllegalStateException - if this EntityManager has been closed.public void remove(Object entity)
remove in interface EntityManagerLiteentity - The entity instanceIllegalArgumentException - if not an entity or if a detached entityIllegalStateException - if this EntityManager has been closed.public <T> T find(Class<T> entityClass, Object primaryKey)
find in interface EntityManagerLiteT - the object type of the entityentityClass - The class of the entityprimaryKey - The primary key as ObjectIllegalStateException - if this EntityManager has been closed.IllegalArgumentException - if the first argument does
not denote an entity type or the second
argument is not a valid type for that
entity's primary keypublic <T> T getReference(Class<T> entityClass, Object primaryKey)
EntityNotFoundException when the instance state is
first accessed.
The application should not expect that the instance state will
be available upon detachment, unless it was accessed by the
application while the entity manager was open.getReference in interface EntityManagerLiteT - the object type of the entityentityClass - The class of the entityprimaryKey - The primary key as ObjectIllegalArgumentException - if the first argument does
not denote an entity type or the second
argument is not a valid type for that
entity's primary keyjavax.persistence.EntityNotFoundException - if the entity state
cannot be accessedIllegalStateException - if this EntityManager has been closed.public void flush()
flush in interface EntityManagerLitejavax.persistence.PersistenceException - if the flush failsIllegalStateException - if this EntityManager has been closed.public void setFlushMode(javax.persistence.FlushModeType flushMode)
setFlushMode in interface EntityManagerLiteflushMode - The flush modeIllegalStateException - if this EntityManager has been closed.public javax.persistence.FlushModeType getFlushMode()
getFlushMode in interface EntityManagerLiteIllegalStateException - if this EntityManager has been closed.public void lock(Object entity, javax.persistence.LockModeType lockMode)
lock in interface EntityManagerLiteentity - lockMode - UnsupportedOperationExceptionpublic void clear()
clear in interface EntityManagerLiteIllegalStateException - if this EntityManager has been closed.public boolean contains(Object entity)
contains in interface EntityManagerLiteentity - The entity instancetrue if the instance belongs to
the current persistence context.IllegalArgumentException - if not an entityIllegalStateException - if this EntityManager has been closed.public javax.persistence.Query createNamedQuery(String name)
createNamedQuery in interface EntityManagerLitename - The name of a queryIllegalArgumentException - if a query has not been
defined with the given nameIllegalStateException - if this EntityManager has been closed.public void joinTransaction()
joinTransaction in interface EntityManagerLiteUnsupportedOperationExceptionpublic Object getDelegate()
getDelegate in interface EntityManagerLiteIllegalStateException - if this EntityManager has been closed.public void close()
close in interface EntityManagerLiteIllegalStateException - if the EntityManager
is container-managed or has been already closed.public boolean isOpen()
isOpen in interface EntityManagerLitepublic javax.persistence.EntityTransaction getTransaction()
getTransaction in interface EntityManagerLiteThis documentation is licensed by Andrew Bowley under the GPLv3 License.