@ComponentSpecification public interface PersistenceManager
PersistenceManager
acts as delegation to the GenericDao
responsible
for the according GenericEntity
in
the invoked methods. This guarantees that individual custom logic is also invoked in case of generic
access. TransactionExecutor
.EntityManager
Modifier and Type | Method and Description |
---|---|
<ID,ENTITY extends GenericEntity<ID>> |
create(Class<ENTITY> entityClass)
This method creates a new and transient instance for the given
entityClass . |
void |
delete(GenericEntity<?> entity)
This method deletes the given
entity . |
<ID,ENTITY extends GenericEntity<ID>> |
find(Class<ENTITY> entityClass,
ID id)
|
<ID,ENTITY extends GenericEntity<ID>> |
findIfExists(Class<ENTITY> entityClass,
ID id)
|
<ID,ENTITY extends GenericEntity<ID>> |
getDao(Class<ENTITY> entityClass)
|
Class<? extends GenericEntity<?>> |
getEntityClass(GenericEntity<?> entity)
|
<ID,ENTITY extends GenericEntity<ID>> |
getReference(Class<ENTITY> entityClass,
ID id)
This method creates a lazy reference proxy of the
GenericEntity with the given
entityClass and id from the persistent store. |
boolean |
hasDao(Class<? extends GenericEntity<?>> entityClass)
This method determines if the
DAO for the given entityClass is
available. |
void |
save(GenericEntity<?> entity)
This method saves the given
entity . |
static final String CDI_NAME
CDI name
.boolean hasDao(Class<? extends GenericEntity<?>> entityClass)
DAO
for the given entityClass
is
available. This can be useful to prevent exceptions.entityClass
- is the type of the GenericEntity
for which the according GenericDao
is
requested.true
if getDao(Class)
will return a valid DAO for the given
entityClass
, false
otherwise (if an exception would be thrown).<ID,ENTITY extends GenericEntity<ID>> GenericDao<ID,ENTITY> getDao(Class<ENTITY> entityClass) throws ObjectNotFoundException
ENTITY
- is the generic entity-type.ID
- is the type of the primary key
.entityClass
- is the type of the GenericEntity
for which the according GenericDao
is
requested.GenericDao
responsible for the given entityClass
.ObjectNotFoundException
- if the requested DAO
could NOT be found.<ID,ENTITY extends GenericEntity<ID>> ENTITY find(Class<ENTITY> entityClass, ID id) throws ObjectNotFoundException
ENTITY
- is the generic type of the entityClass
.ID
- is the type of the primary key
.entityClass
- is the class reflecting the type of the requested entity.id
- is the primary key
of the requested entity.ObjectNotFoundException
- if the requested entity
could NOT be found.GenericDao.find(Object)
<ID,ENTITY extends GenericEntity<ID>> ENTITY findIfExists(Class<ENTITY> entityClass, ID id)
ENTITY
- is the generic type of the entityClass
.ID
- is the type of the primary key
.entityClass
- is the class reflecting the type of the requested entity.id
- is the primary key
of the requested entity.null
if it does NOT exist.GenericDao.findIfExists(Object)
<ID,ENTITY extends GenericEntity<ID>> ENTITY getReference(Class<ENTITY> entityClass, ID id) throws ObjectNotFoundException
GenericEntity
with the given
entityClass
and id
from the persistent store.ID
- is the type of the primary key
.ENTITY
- is the generic type of the entityClass
.entityClass
- is the class reflecting the type of the requested entity.id
- is the primary key
of the requested entity.ObjectNotFoundException
- if the requested entity
could NOT be found.GenericDao.getReference(Object)
<ID,ENTITY extends GenericEntity<ID>> ENTITY create(Class<ENTITY> entityClass)
entityClass
. ID
- is the type of the primary key
.ENTITY
- is the generic type of the entityClass
.entityClass
- is the Class
reflecting the entity to create. This may also be the interface
of the entity.GenericDao.create()
void save(GenericEntity<?> entity)
entity
. entity
- is the entity to save.GenericDao.save(GenericEntity)
void delete(GenericEntity<?> entity)
entity
. entity
- is the entity to delete.GenericDao.delete(GenericEntity)
Class<? extends GenericEntity<?>> getEntityClass(GenericEntity<?> entity)
Class
reflecting the given entity
. Unlike
entity.#getClass()
this method will always return the real
class defining the entity
. entity.#getClass()
will return the
Class
of the proxy instead. In such case this method will return the real entity-class adapted by
the proxy.entity
- is the GenericEntity
for which the class is requested.Class
reflecting the given entity
.Copyright © 2001–2014 mmm-Team. All rights reserved.