Class CachingBatchableLocalEntityProvider<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.CachingMutableLocalEntityProvider<T>
com.vaadin.featurepack.data.jpacontainer.provider.CachingBatchableLocalEntityProvider<T>
- All Implemented Interfaces:
BatchableEntityProvider<T>,CachingEntityProvider<T>,EntityProvider<T>,EntityProviderChangeNotifier<T>,MutableEntityProvider<T>,Serializable
- Direct Known Subclasses:
CachingBatchableEntityProvider
public class CachingBatchableLocalEntityProvider<T>
extends CachingMutableLocalEntityProvider<T>
implements BatchableEntityProvider<T>
A very simple implementation of
BatchableEntityProvider with caching
support that simply passes itself to the BatchableEntityProvider.BatchUpdateCallback. No data
consistency checks are performed.- 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
ConstructorsConstructorDescriptionCachingBatchableLocalEntityProvider(Class<T> entityClass) Creates a newCachingBatchableLocalEntityProvider.CachingBatchableLocalEntityProvider(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a newCachingBatchableLocalEntityProvider. -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes a batch update using the specified callback parameter.Methods inherited from class com.vaadin.featurepack.data.jpacontainer.provider.CachingMutableLocalEntityProvider
addEntity, containsEntity, flush, getAllEntityIdentifiers, getEntity, getEntityCacheMaxSize, getEntityCount, getEntityIdentifierAt, getFirstEntityIdentifier, getLastEntityIdentifier, getNextEntityIdentifier, getPreviousEntityIdentifier, isCacheEnabled, isCloneCachedEntities, isEntitiesDetached, refresh, refreshEntity, removeEntity, setCacheEnabled, setCloneCachedEntities, setEntityCacheMaxSize, updateEntity, updateEntityProperty, usesCacheMethods inherited from class com.vaadin.featurepack.data.jpacontainer.provider.MutableLocalEntityProvider
addListener, fireEntityProviderChangeEvent, isFireEntityProviderChangeEvent, isTransactionsHandledByProvider, removeListener, runInTransaction, setFireEntityProviderChangeEvents, setTransactionsHandledByProviderMethods inherited from class com.vaadin.featurepack.data.jpacontainer.provider.LocalEntityProvider
addPrimaryKeyToSortList, createFilteredQuery, createSiblingQuery, createUnsortedFilteredQuery, detachEntity, doContainsEntity, doGetAllEntityIdentifiers, doGetEntity, doGetEntityCount, doGetEntityIdentifierAt, doGetEntityManager, doGetFirstEntityIdentifier, doGetLastEntityIdentifier, doGetNextEntityIdentifier, doGetPreviousEntityIdentifier, getEntityClassMetadata, getEntityManager, getEntityManagerProvider, getIdentifier, getLazyLoadingDelegate, getQueryModifierDelegate, getSibling, readResolve, 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.CachingEntityProvider
setEntitiesDetachedMethods inherited from interface com.vaadin.featurepack.data.jpacontainer.EntityProvider
containsEntity, getAllEntityIdentifiers, getEntity, getEntityCount, getEntityIdentifierAt, getEntityManager, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, refresh, refreshEntity, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegateMethods inherited from interface com.vaadin.featurepack.data.jpacontainer.MutableEntityProvider
addEntity, removeEntity, updateEntity, updateEntityProperty
-
Constructor Details
-
CachingBatchableLocalEntityProvider
Creates a newCachingBatchableLocalEntityProvider. The entity manager must be set usingLocalEntityProvider.setEntityManager(javax.persistence.EntityManager).- Parameters:
entityClass- the entity class (must not be null).
-
CachingBatchableLocalEntityProvider
public CachingBatchableLocalEntityProvider(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a newCachingBatchableLocalEntityProvider.- 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.
-