|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.addon.jpacontainer.provider.LocalEntityProvider<T>
com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider<T>
public class MutableLocalEntityProvider<T>
Extended version of LocalEntityProvider that provides editing
support. Transactions can either be handled internally by the provider, or by
an external container such as Spring or EJB (see the JPAContainer manual for
examples of how to do this). By default, transactions are handled internally
by invoking the transaction methods of the EntityManager.
This entity provider fires EntityProviderChangeEvents every time an
entity is added, updated or deleted.
| Constructor Summary | |
|---|---|
MutableLocalEntityProvider(Class<T> entityClass)
Creates a new MutableLocalEntityProvider. |
|
MutableLocalEntityProvider(Class<T> entityClass,
javax.persistence.EntityManager entityManager)
Creates a new MutableLocalEntityProvider. |
|
| Method Summary | |
|---|---|
T |
addEntity(T entity)
Adds entity to the persistence storage. |
void |
addListener(EntityProviderChangeListener<T> listener)
Registers listener to be notified of
EntityProviderChangeEvents. |
protected void |
fireEntityProviderChangeEvent(EntityProviderChangeEvent<T> event)
Sends event to all registered listeners if
isFireEntityProviderChangeEvent() is true. |
protected boolean |
isFireEntityProviderChangeEvent()
Returns whether EntityProviderChangeEvents should be fired by
this entity provider. |
boolean |
isTransactionsHandledByProvider()
Returns whether the entity provider is handling transactions internally (the default) or relies on external transaction handling. |
void |
removeEntity(Object entityId)
Removes the entity identified by entityId. |
void |
removeListener(EntityProviderChangeListener<T> listener)
Removes the previously registered listener. |
protected void |
runInTransaction(Runnable operation)
If isTransactionsHandledByProvider() is true,
operation will be executed inside a transaction that is
commited after the operation is completed. |
protected void |
setFireEntityProviderChangeEvents(boolean fireEvents)
Sets whether EntityProviderChangeEvents should be fired by this
entity provider. |
void |
setTransactionsHandledByProvider(boolean transactionsHandled)
Specifies whether the entity provider should handle transactions itself or whether they should be handled outside (e.g. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MutableLocalEntityProvider(Class<T> entityClass)
MutableLocalEntityProvider. The entity manager
must be set using
LocalEntityProvider.setEntityManager(javax.persistence.EntityManager).
entityClass - the entity class (must not be null).
public MutableLocalEntityProvider(Class<T> entityClass,
javax.persistence.EntityManager entityManager)
MutableLocalEntityProvider.
entityClass - the entity class (must not be null).entityManager - the entity manager to use (must not be null).| Method Detail |
|---|
public void setTransactionsHandledByProvider(boolean transactionsHandled)
transactionsHandled - true to handle the transactions internally, false to rely on
external transaction handling.public boolean isTransactionsHandledByProvider()
protected void runInTransaction(Runnable operation)
isTransactionsHandledByProvider() is true,
operation will be executed inside a transaction that is
commited after the operation is completed. Otherwise,
operation will just be executed.
operation - the operation to run (must not be null).public T addEntity(T entity)
MutableEntityProviderentity 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.
addEntity in interface MutableEntityProvider<T>entity - the entity to add (must not be null).
public void removeEntity(Object entityId)
MutableEntityProviderentityId. If no entity is
found, nothing happens.
removeEntity in interface MutableEntityProvider<T>entityId - the identifier of the entity to remove.public T updateEntity(T entity)
MutableEntityProviderentity 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.
updateEntity in interface MutableEntityProvider<T>entity - the entity to update (must not be null).
public void updateEntityProperty(Object entityId,
String propertyName,
Object propertyValue)
throws IllegalArgumentException
MutableEntityProvider
updateEntityProperty in interface MutableEntityProvider<T>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.public void addListener(EntityProviderChangeListener<T> listener)
EntityProviderChangeNotifierlistener to be notified of
EntityProviderChangeEvents.
addListener in interface EntityProviderChangeNotifier<T>listener - the listener to register (must not be null).public void removeListener(EntityProviderChangeListener<T> listener)
EntityProviderChangeNotifier
removeListener in interface EntityProviderChangeNotifier<T>listener - the listener to remove (must not be null).protected void setFireEntityProviderChangeEvents(boolean fireEvents)
EntityProviderChangeEvents should be fired by this
entity provider.
protected boolean isFireEntityProviderChangeEvent()
EntityProviderChangeEvents should be fired by
this entity provider.
protected void fireEntityProviderChangeEvent(EntityProviderChangeEvent<T> event)
event to all registered listeners if
isFireEntityProviderChangeEvent() is true.
event - the event to send (must not be null).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||