nl.gx.webmanager.services.entitymanager
Interface EntityManager

All Known Subinterfaces:
PersistenceContextEntityManager

public interface EntityManager

EntityManager interface.

Author:
bartk

Method Summary
<T> T
copy(T entity)
          Copies an entity and the entire tree of its children.
 void delete(java.lang.Object entity)
          Deletes an entity from the persistence backend
 java.lang.Object find(WmId primaryKey)
          Looks up an entity by its id
<T> java.util.Set<T>
getAll(java.lang.Class<T> entity)
          Returns all entities of the specified type.
 WmId getId(java.lang.Object entity)
          Get ID from the given entity.
<T> T
getInstance(java.lang.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.
 java.lang.Object getInstance(java.lang.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(java.lang.String idString)
          Returns a WmId object that corresponds to the idString.
 boolean isManageable(java.lang.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(java.lang.Object entity, java.lang.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(java.lang.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(java.lang.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

java.lang.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(java.lang.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> java.util.Set<T> getAll(java.lang.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(java.lang.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 the persist() 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

java.lang.Object getInstance(java.lang.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 the persist() 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(java.lang.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.

removeProperty

void removeProperty(java.lang.Object entity,
                    java.lang.String property)
Remove named property from the persistent image of the given entity.

Parameters:
entity - entity for property removal.
property - name of the property to remove.


Copyright © 2007-2011 GX Software BV. All Rights Reserved.