com.vaadin.addon.jpacontainer.provider
Class BatchableLocalEntityProvider<T>
java.lang.Object
com.vaadin.addon.jpacontainer.provider.LocalEntityProvider<T>
com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider<T>
com.vaadin.addon.jpacontainer.provider.BatchableLocalEntityProvider<T>
- All Implemented Interfaces:
- BatchableEntityProvider<T>, EntityProvider<T>, EntityProviderChangeNotifier<T>, MutableEntityProvider<T>, Serializable
public class BatchableLocalEntityProvider<T>
- extends MutableLocalEntityProvider<T>
- implements BatchableEntityProvider<T>
A very simple implementation of BatchableEntityProvider that simply
passes itself to the BatchUpdateCallback. No data consistency checks
are performed. On some occations, this can cause trouble in real
applications. Please see the BatchableEntityProvider interface
JavaDocs and the JPAContainer manual for more information.
- Since:
- 1.0
- Author:
- Petter Holmström (Vaadin Ltd)
- See Also:
- Serialized Form
| Methods inherited from class com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider |
addEntity, addListener, fireEntityProviderChangeEvent, isFireEntityProviderChangeEvent, isTransactionsHandledByProvider, removeEntity, removeListener, runInTransaction, setFireEntityProviderChangeEvents, setTransactionsHandledByProvider, updateEntity, updateEntityProperty |
| Methods inherited from class com.vaadin.addon.jpacontainer.provider.LocalEntityProvider |
addPrimaryKeyToSortList, containsEntity, createFilteredQuery, createSiblingQuery, createUnsortedFilteredQuery, detachEntity, doContainsEntity, doGetAllEntityIdentifiers, doGetEntity, doGetEntityCount, doGetEntityIdentifierAt, doGetEntityManager, doGetFirstEntityIdentifier, doGetLastEntityIdentifier, doGetNextEntityIdentifier, doGetPreviousEntityIdentifier, getAllEntityIdentifiers, getEntity, getEntityClassMetadata, getEntityCount, getEntityIdentifierAt, getEntityManager, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, getSibling, isEntitiesDetached, readResolve, refresh, refreshEntity, setEntitiesDetached, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegate, translateSortBy, writeReplace |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.vaadin.addon.jpacontainer.EntityProvider |
containsEntity, getAllEntityIdentifiers, getEntity, getEntityCount, getEntityIdentifierAt, getEntityManager, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, isEntitiesDetached, refresh, refreshEntity, setEntitiesDetached, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegate |
BatchableLocalEntityProvider
public BatchableLocalEntityProvider(Class<T> entityClass)
- Creates a new
BatchableLocalEntityProvider. The entity
manager must be set using
LocalEntityProvider.setEntityManager(javax.persistence.EntityManager).
- Parameters:
entityClass - the entity class (must not be null).
BatchableLocalEntityProvider
public BatchableLocalEntityProvider(Class<T> entityClass,
javax.persistence.EntityManager entityManager)
- Creates a new
BatchableLocalEntityProvider.
- Parameters:
entityClass - the entity class (must not be null).entityManager - the entity manager to use (must not be null).
batchUpdate
public void batchUpdate(BatchableEntityProvider.BatchUpdateCallback<T> callback)
throws UnsupportedOperationException
- Description copied from interface:
BatchableEntityProvider
- Executes a batch update using the specified callback parameter. The batch
update should be run inside a single transaction. The implementation may
either handle the transaction itself, or rely on external transaction
handling provided by a container such as Spring or EJB. If the batch
update fails, the entire transaction should be rolled back and an
exception thrown. Otherwise, it should be committed.
Clients should instantiate BatchableEntityProvider.BatchUpdateCallback, implement the
BatchableEntityProvider.BatchUpdateCallback.batchUpdate(MutableEntityProvider) method and
execute the updates as if they were using an ordinary
MutableEntityProvider. The following example saves a list of
transient entities:
provider.batchUpdate(new BatchUpdateCallback() {
public void batchUpdate(MutableEntityProvider batchEnabledEntityProvider) {
for (Entity e : myListOfEntitiesToAdd) {
batchEnabledEntityProvider.addEntity(e);
}
}
});
- Specified by:
batchUpdate in interface BatchableEntityProvider<T>
- Parameters:
callback - the callback that will be used to run the batch update.
- Throws:
UnsupportedOperationException - if this entity provider does not support batch updates.
Copyright © 2013 Vaadin Ltd. All rights reserved.