public interface IIvyEntityManager
EntityManager
but is more easy to use. It is not necessary to begin first an transaction before
persist an entity or do some other operations. This means the Transaction is managed itself by this entity
manager. It also supports detached entities for all operations, the EntityManager
supports only
detached entities for the method EntityManager.merge(Object)
.
An IIvyEntityManager
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. This interface
defines the methods that are used to interact with the persistence context. The IIvyEntityManager
API is used to create and remove persistent entity instances, to find entities by their primary key, and to
query over entities.
Modifier and Type | Method and Description |
---|---|
javax.persistence.EntityManager |
createEntityManager()
Create a new EntityManager.
|
javax.persistence.EntityManager |
createEntityManager(Map<?,?> properties)
Create a new EntityManager with the specified Map of properties.
|
IIvyQuery |
createNamedQuery(String name)
Create an instance of Query for executing a named query (in the Java Persistence query language or in
native SQL).
|
IIvyQuery |
createNativeQuery(String sqlString)
Create an instance of Query for executing a native SQL statement, e.g., for update or delete.
|
IIvyQuery |
createNativeQuery(String sqlString,
Class resultClass)
Create an instance of Query for executing a native SQL query.
|
IIvyQuery |
createNativeQuery(String sqlString,
String resultSetMapping)
Create an instance of Query for executing a native SQL query.
|
IIvyQuery |
createQuery(String qlString)
Create an instance of Query for executing a Java Persistence query language statement.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find an entity by the given primary key on the database
|
<T> List<T> |
findAll(Class<T> entityClass)
Find all entities instances of the given type on the database
|
<T> T |
merge(T entity)
Merge the state of the given entity into the database
|
<T> T |
persist(T entity)
Make an entity instance persistent in the database
|
<T> T |
refresh(T entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
|
<T> T |
remove(T entity)
Remove the given entity instance from the database
|
<T> T find(Class<T> entityClass, Object primaryKey)
T
- the type of the entityentityClass
- the type of the entityprimaryKey
- the primary key of the entitynull
if the entity does not existIllegalArgumentException
- if the first argument does not denote an entity type or the second
argument is not a valid type for that entity's primary keyEntityManager.find(Class, Object)
<T> List<T> findAll(Class<T> entityClass)
T
- the type of the entitiesentityClass
- the type of the entitiesIllegalArgumentException
- if the first argument does not denote an entity typeEntityManager.find(Class, Object)
<T> T persist(T entity)
T
- the type of the entityentity
- the entity instance which will be persistent, this object will be directly modifiedjavax.persistence.EntityExistsException
- if the entity already exists. (The EntityExistsException may be thrown when
the persist operation is invoked, or the EntityExistsException or another PersistenceException
may be thrown at flush or commit time.)IllegalArgumentException
- if not an entityEntityManager.persist(Object)
<T> T merge(T entity)
T
- the type of the entityentity
- the entity instance which will be merged, this object is not changedIllegalArgumentException
- if instance is not an entity or is a removed entityEntityManager.merge(Object)
<T> T refresh(T entity)
T
- the type of the entityentity
- the entity instance which will be refreshed, this object will be directly modifiedIllegalArgumentException
- if not an entity or entity is not managedjavax.persistence.EntityNotFoundException
- if the entity no longer exists in the database.EntityManager.refresh(Object)
<T> T remove(T entity)
T
- the type of the entityentity
- the entity instance which will be removed, the entity is not modifiedIllegalArgumentException
- if not an entityEntityManager.remove(Object)
IIvyQuery createQuery(String qlString)
qlString
- a Java Persistence query language query stringIllegalArgumentException
- if query string is not validIIvyQuery createNamedQuery(String name)
name
- the name of a query defined in metadataIllegalArgumentException
- if a query has not been defined with the given nameIIvyQuery createNativeQuery(String sqlString)
sqlString
- a native SQL query stringIIvyQuery createNativeQuery(String sqlString, Class resultClass)
sqlString
- a native SQL query stringresultClass
- the class of the resulting instance(s)IIvyQuery createNativeQuery(String sqlString, String resultSetMapping)
sqlString
- a native SQL query stringresultSetMapping
- the name of the result set mappingjavax.persistence.EntityManager createEntityManager()
EntityManager
instanceEntityManager
javax.persistence.EntityManager createEntityManager(Map<?,?> properties)
properties
- a map of additional propertiesEntityManager
instanceEntityManager
Copyright © 2024
AXON IVY AG
All Rights Reserved Documentation was generated
on May 5, 2024