|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MutableEntityProvider<T>
Entity provider that also supports adding, updating and removing entities.
Implementations should pay special attention to the usage of the
EntityProvider.isEntitiesDetached() property.
All the methods defined in this interface should run in their own transactions. The implementation may either handle the transactions itself, or rely on declarative transaction handling as provided by e.g. Spring or EJB. If a method completes successfully, its transaction should be committed. If an error occurs while accessing the persistence storage, the transaction should be rolled back and a runtime exception should be thrown.
| Method Summary | |
|---|---|
T |
addEntity(T entity)
Adds entity to the persistence storage. |
void |
removeEntity(Object entityId)
Removes the entity identified by entityId. |
T |
updateEntity(T entity)
Saves the changes made to entity to the persistence storage. |
void |
updateEntityProperty(Object entityId,
String propertyName,
Object propertyValue)
Updates a single property value of a specific entity. |
| Method Detail |
|---|
T addEntity(T entity)
throws RuntimeException
entity to the persistence storage. This method returns
the same entity after adding to make it possible for the client to access
the entity identifier. Note, however, that depending on the
implementation of the entity provider and the state of
EntityProvider.isEntitiesDetached(), this may or may not be the same instance
as entity. Therefore, if EntityProvider.isEntitiesDetached() is
true, clients should always assume that
entity != returnedEntity.
entity - the entity to add (must not be null).
RuntimeException - if an error occurs while adding the entity to the persistence
storage.
T updateEntity(T entity)
throws RuntimeException
entity to the persistence storage.
This method returns the same entity after saving the changes. Note,
however, that depending on the implementation of the entity provider and
the state of EntityProvider.isEntitiesDetached(), this may or may not be the
same instance as entity. Therefore, if
EntityProvider.isEntitiesDetached() is true, clients should always assume that
entity != returnedEntity.
entity - the entity to update (must not be null).
RuntimeException - if an error occurs while saving the changes to the
persistence storage.
void updateEntityProperty(Object entityId,
String propertyName,
Object propertyValue)
throws IllegalArgumentException,
RuntimeException
entityId - the identifier of the entity (must not be null).propertyName - the name of the property to update (must not be null).propertyValue - the new property value.
IllegalArgumentException - if propertyName is not a valid property name.
RuntimeException - if an error occurs while saving the change to the persistence
storage.
void removeEntity(Object entityId)
throws RuntimeException
entityId. If no entity is
found, nothing happens.
entityId - the identifier of the entity to remove.
RuntimeException - if an error occurs while removing the entity from the
persistence storage.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||