Interface EntityManager
-
- All Known Subinterfaces:
PersistenceContextEntityManager
public interface EntityManager
EntityManager interface.- Author:
- bartk
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
copy(T entity)
Copies an entity and the entire tree of its children.void
delete(Object entity)
Deletes an entity from the persistence backendObject
find(WmId primaryKey)
Looks up an entity by its id<T> Set<T>
getAll(Class<T> entity)
Returns all entities of the specified type.WmId
getId(Object entity)
Get ID from the given entity.<T> T
getInstance(Class<T> entityClass)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface.Object
getInstance(String entityClassname)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface.WmId
getWmId(String idString)
Returns a WmId object that corresponds to the idString.boolean
isManageable(Class<?> clazz)
Determine if the given class is manageable by the Entity Manager.<T> T
persist(T entity)
Persists an entity which is not yet persisted (i.e.void
removeProperty(Object entity, String property)
Remove named property from the persistent image of the given entity.<T> T
save(T entity)
Saves an entity that was persisted before (i.e.
-
-
-
Method Detail
-
getId
WmId getId(Object entity)
Get ID from the given entity.- Parameters:
entity
- entity to get the ID from.- Returns:
- WM ID of the entity.
-
getWmId
WmId getWmId(String idString)
Returns a WmId object that corresponds to the idString. The idString is generally the result of WmId.toString() so this method performs the reverse action of WmId.toString()- Parameters:
idString
- a String-representation of a WmId- Returns:
- WM ID class from the string representation.
-
find
Object find(WmId primaryKey)
Looks up an entity by its id- Parameters:
primaryKey
- the id identifying the entity to load- Returns:
- the requested entity or null if it wasn't found
-
persist
<T> T persist(T entity)
Persists an entity which is not yet persisted (i.e. which doesn't have its' WmId filled in yet)- Type Parameters:
T
- The type of the entity to persist- Parameters:
entity
- The entity to persist- Returns:
- The persisted entity with its WmId filled in.
-
copy
<T> T copy(T entity) throws DomainException
Copies an entity and the entire tree of its children. This method traverses all @Child relations.- Type Parameters:
T
- the type of the entity to copy- Parameters:
entity
- the entity to copy- Returns:
- the copied entity with its new WmId filled in.
- Throws:
DomainException
- when something went wrong while copying the entity
-
delete
void delete(Object entity) throws DomainException
Deletes an entity from the persistence backend- Parameters:
entity
- The entity to be deleted- Throws:
DomainException
- when something went wrong while deleting the entity
-
save
<T> T save(T entity) throws DomainException
Saves an entity that was persisted before (i.e. which does have its' WmId filled in)- Type Parameters:
T
- The type of the entity to persist- Parameters:
entity
- The entity to persist- Returns:
- The entity
- Throws:
DomainException
- when something went wrong while saving the entity
-
getAll
<T> Set<T> getAll(Class<T> entity)
Returns all entities of the specified type.- Type Parameters:
T
- The requested type- Parameters:
entity
- the Class of the requested type- Returns:
- set of all managed instance of the given class.
-
getInstance
<T> T getInstance(Class<T> entityClass)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface. In order to persist such an entity, invoke thepersist()
method.- Type Parameters:
T
- The type of Class to instantiate- Parameters:
entityClass
- The Class to get an instance of (is generally the interface of the required Class)- Returns:
- a newly created instance of the requested Class
-
getInstance
Object getInstance(String entityClassname)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface. In order to persist such an entity, invoke thepersist()
method.- Parameters:
entityClassname
- The Class to get an instance of (is generally the interface of the required Class)- Returns:
- a newly created instance of the requested Class
-
isManageable
boolean isManageable(Class<?> clazz)
Determine if the given class is manageable by the Entity Manager. This may involve more than just checking if the class is identifiable. Additional checks are delegated to the Entity Domain of the class.- Parameters:
clazz
- class to check for manageability.- Returns:
true
if the class can be managed by the EM.
-
-