@Component(value="cuba_EntityManager") @Scope(value="prototype") public class EntityManagerImpl extends java.lang.Object implements EntityManager
NAME| Modifier and Type | Method and Description |
|---|---|
Query |
createNativeQuery()
Create an instance of Query for executing a native SQL statement, e.g., for update or delete.
|
Query |
createNativeQuery(java.lang.String sql)
Create an instance of Query for executing a native SQL statement, e.g., for update or delete.
|
<T extends io.jmix.core.Entity> |
createNativeQuery(java.lang.String sql,
java.lang.Class<T> resultClass)
Create an instance of Query for executing a native SQL statement and map its result to an entity.
|
Query |
createQuery()
Create an instance of Query for executing a Java Persistence query language statement.
|
Query |
createQuery(java.lang.String qlStr)
Create an instance of Query for executing a Java Persistence query language statement.
|
<T> TypedQuery<T> |
createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
Create a type-safe instance of Query for executing a Java Persistence query language statement.
|
void |
detach(io.jmix.core.Entity entity) |
void |
fetch(io.jmix.core.Entity entity,
io.jmix.core.FetchPlan fetchPlan)
Deprecated.
|
<T extends io.jmix.core.Entity,K> |
find(java.lang.Class<T> entityClass,
K id)
Find by primary key.
|
<T extends io.jmix.core.Entity,K> |
find(java.lang.Class<T> entityClass,
K id,
io.jmix.core.FetchPlan... fetchPlans)
Find by primary key.
|
<T extends io.jmix.core.Entity,K> |
find(java.lang.Class<T> entityClass,
K id,
java.lang.String... fetchPlanNames)
Find by primary key.
|
void |
flush()
Synchronize the persistence context to the underlying database.
|
java.sql.Connection |
getConnection() |
javax.persistence.EntityManager |
getDelegate() |
<T extends io.jmix.core.Entity,K> |
getReference(java.lang.Class<T> clazz,
K id)
Get an instance, whose state may be lazily fetched.
If the requested instance does not exist in the database, the EntityNotFoundException is thrown 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. |
boolean |
isSoftDeletion() |
<T extends io.jmix.core.Entity> |
merge(T entity)
Merge the state of the given entity into the current persistence context.
|
<T extends io.jmix.core.Entity> |
merge(T entity,
io.jmix.core.FetchPlan fetchPlan)
Deprecated.
|
<T extends io.jmix.core.Entity> |
merge(T entity,
java.lang.String fetchPlanName)
Deprecated.
|
void |
persist(io.jmix.core.Entity entity)
Make an instance managed and persistent.
|
<T extends io.jmix.core.Entity,K> |
reload(java.lang.Class<T> entityClass,
K id,
java.lang.String... fetchPlanNames)
DEPRECATED since v.6.
|
<T extends io.jmix.core.Entity> |
reload(T entity,
java.lang.String... fetchPlanNames)
Reload an entity from DB according to a combined fetch plan defined by the given array of fetch plans.
|
<T extends io.jmix.core.Entity> |
reloadNN(T entity,
java.lang.String... fetchPlanNames)
Reload an entity from DB according to a combined fetch plan defined by the given array of fetch plans.
|
void |
remove(io.jmix.core.Entity entity)
Remove the entity instance.
|
void |
setSoftDeletion(boolean softDeletion)
Set SoftDeletion mode for this EntityManager.
|
public javax.persistence.EntityManager getDelegate()
getDelegate in interface EntityManagerpublic boolean isSoftDeletion()
isSoftDeletion in interface EntityManagerpublic void setSoftDeletion(boolean softDeletion)
EntityManagersetSoftDeletion in interface EntityManagersoftDeletion - modepublic void persist(io.jmix.core.Entity entity)
EntityManagerpersist in interface EntityManagerentity - entity instancepublic <T extends io.jmix.core.Entity> T merge(T entity)
EntityManagerIf a new or patch entity (see PersistenceHelper methods) with non-null ID is passed to merge,
EntityManager loads the corresponding object from the database and updates it with non-null values
of attributes of the passed entity. If the object does not exist in the database, the passed entity is persisted
and returned.
merge in interface EntityManagerentity - entity instanceEntityStates.isNew(Object),
EntityStates.makePatch(Object)@Deprecated
public <T extends io.jmix.core.Entity> T merge(T entity,
@Nullable
io.jmix.core.FetchPlan fetchPlan)
EntityManagerio.jmix.core.sys.EntityFetcher#fetch(Entity, FetchPlan) if needed.merge in interface EntityManager@Deprecated
public <T extends io.jmix.core.Entity> T merge(T entity,
@Nullable
java.lang.String fetchPlanName)
EntityManagerio.jmix.core.sys.EntityFetcher#fetch(Entity, String) if needed.merge in interface EntityManagerpublic void remove(io.jmix.core.Entity entity)
EntityManagerEntityManager.isSoftDeletion() flag.remove in interface EntityManagerentity - entity instancepublic <T extends io.jmix.core.Entity,K> T find(java.lang.Class<T> entityClass,
K id)
EntityManagerfind in interface EntityManagerentityClass - entity classid - entity id@Nullable
public <T extends io.jmix.core.Entity,K> T find(java.lang.Class<T> entityClass,
K id,
io.jmix.core.FetchPlan... fetchPlans)
EntityManager
Due to accepting fetch plans, this method actually executes a Query which may lead to flushing of the
persistence context and invoking listeners on modified entities.
find in interface EntityManagerentityClass - entity classid - entity idfetchPlans - array of fetch plans@Nullable
public <T extends io.jmix.core.Entity,K> T find(java.lang.Class<T> entityClass,
K id,
java.lang.String... fetchPlanNames)
EntityManager
Due to accepting fetch plans, this method actually executes a Query which may lead to flushing of the
persistence context and invoking listeners on modified entities.
find in interface EntityManagerentityClass - entity classid - entity idfetchPlanNames - array of fetch plan names for this entitypublic <T extends io.jmix.core.Entity,K> T getReference(java.lang.Class<T> clazz,
K id)
EntityManagergetReference in interface EntityManagerclazz - entity classid - entity idpublic Query createQuery()
EntityManagercreateQuery in interface EntityManagerpublic Query createQuery(java.lang.String qlStr)
EntityManagercreateQuery in interface EntityManagerqlStr - a Java Persistence query stringpublic <T> TypedQuery<T> createQuery(java.lang.String qlString, java.lang.Class<T> resultClass)
EntityManagercreateQuery in interface EntityManagerqlString - a Java Persistence query stringresultClass - expected result classpublic Query createNativeQuery()
EntityManagercreateNativeQuery in interface EntityManagerpublic Query createNativeQuery(java.lang.String sql)
EntityManagercreateNativeQuery in interface EntityManagersql - a native SQL query stringpublic <T extends io.jmix.core.Entity> TypedQuery<T> createNativeQuery(java.lang.String sql, java.lang.Class<T> resultClass)
EntityManagercreateNativeQuery in interface EntityManagersql - a native SQL query stringresultClass - expected result class@Deprecated
public void fetch(io.jmix.core.Entity entity,
io.jmix.core.FetchPlan fetchPlan)
EntityManagerfetch in interface EntityManager@Nullable
public <T extends io.jmix.core.Entity,K> T reload(java.lang.Class<T> entityClass,
K id,
java.lang.String... fetchPlanNames)
EntityManagerEntityManager.find(Class, Object, String...)reload in interface EntityManager@Nullable
public <T extends io.jmix.core.Entity> T reload(T entity,
java.lang.String... fetchPlanNames)
EntityManagerreload in interface EntityManagerentity - entity instance to reloadfetchPlanNames - array of fetch plan namespublic <T extends io.jmix.core.Entity> T reloadNN(T entity,
java.lang.String... fetchPlanNames)
EntityManagerreloadNN in interface EntityManagerentity - entity instance to reloadfetchPlanNames - array of fetch plan namespublic void flush()
EntityManagerflush in interface EntityManagerpublic void detach(io.jmix.core.Entity entity)
detach in interface EntityManagerpublic java.sql.Connection getConnection()
getConnection in interface EntityManagerDon't close this connection after use, it will be automatically closed on transaction end.