Class BatchableLocalEntityProvider<T>
java.lang.Object
com.vaadin.featurepack.data.jpacontainer.provider.LocalEntityProvider<T>
com.vaadin.featurepack.data.jpacontainer.provider.MutableLocalEntityProvider<T>
com.vaadin.featurepack.data.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 BatchableEntityProvider.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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.jpacontainer.BatchableEntityProvider
BatchableEntityProvider.BatchUpdateCallback<T> -
Constructor Summary
ConstructorsConstructorDescriptionBatchableLocalEntityProvider(Class<T> entityClass) Creates a newBatchableLocalEntityProvider.BatchableLocalEntityProvider(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a newBatchableLocalEntityProvider. -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes a batch update using the specified callback parameter.Methods inherited from class com.vaadin.featurepack.data.jpacontainer.provider.MutableLocalEntityProvider
addEntity, addListener, fireEntityProviderChangeEvent, isFireEntityProviderChangeEvent, isTransactionsHandledByProvider, removeEntity, removeListener, runInTransaction, setFireEntityProviderChangeEvents, setTransactionsHandledByProvider, updateEntity, updateEntityPropertyMethods inherited from class com.vaadin.featurepack.data.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, writeReplaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.featurepack.data.jpacontainer.EntityProvider
containsEntity, getAllEntityIdentifiers, getEntity, getEntityCount, getEntityIdentifierAt, getEntityManager, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, isEntitiesDetached, refresh, refreshEntity, setEntitiesDetached, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegateMethods inherited from interface com.vaadin.featurepack.data.jpacontainer.MutableEntityProvider
addEntity, removeEntity, updateEntity, updateEntityProperty
-
Constructor Details
-
BatchableLocalEntityProvider
Creates a newBatchableLocalEntityProvider. The entity manager must be set usingLocalEntityProvider.setEntityManager(javax.persistence.EntityManager).- Parameters:
entityClass- the entity class (must not be null).
-
BatchableLocalEntityProvider
public BatchableLocalEntityProvider(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a newBatchableLocalEntityProvider.- Parameters:
entityClass- the entity class (must not be null).entityManager- the entity manager to use (must not be null).
-
-
Method Details
-
batchUpdate
public void batchUpdate(BatchableEntityProvider.BatchUpdateCallback<T> callback) throws UnsupportedOperationException Description copied from interface:BatchableEntityProviderExecutes 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 theBatchableEntityProvider.BatchUpdateCallback.batchUpdate(MutableEntityProvider)method and execute the updates as if they were using an ordinaryMutableEntityProvider. 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:
batchUpdatein interfaceBatchableEntityProvider<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.
-