com.vaadin.addon.jpacontainer.provider.jndijta
Class CachingMutableEntityProvider<T>

java.lang.Object
  extended by com.vaadin.addon.jpacontainer.provider.LocalEntityProvider<T>
      extended by com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider<T>
          extended by com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider<T>
              extended by com.vaadin.addon.jpacontainer.provider.jndijta.CachingMutableEntityProvider<T>
Type Parameters:
T -
All Implemented Interfaces:
CachingEntityProvider<T>, EntityProvider<T>, EntityProviderChangeNotifier<T>, MutableEntityProvider<T>, JndiJtaProvider<T>, Serializable

public class CachingMutableEntityProvider<T>
extends CachingMutableLocalEntityProvider<T>
implements JndiJtaProvider<T>

An entity provider implementation that uses JTA transactions and JPA context provided by the application server. To provide a generic non EJB provider this class gets references to both UserTransaction and EntityManager via JNDI lookup.

See Also:
Serialized Form

Constructor Summary
CachingMutableEntityProvider(Class<T> entityClass)
           
CachingMutableEntityProvider(Class<T> entityClass, JndiAddresses jndiAddresses)
           
 
Method Summary
 javax.persistence.EntityManager getEntityManager()
          Gets the entity manager.
 JndiAddresses getJndiAddresses()
           
 boolean isEntitiesDetached()
          If this method returns true, all entities returned from this entity provider are explicitly detached from the persistence context before returned, regardless of whether the persistence context is extended or transaction-scoped.
protected  void runInTransaction(Runnable operation)
          If MutableLocalEntityProvider.isTransactionsHandledByProvider() is true, operation will be executed inside a transaction that is commited after the operation is completed.
 void setJndiAddresses(JndiAddresses addresses)
           
 
Methods inherited from class com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider
addEntity, containsEntity, flush, getAllEntityIdentifiers, getEntity, getEntityCacheMaxSize, getEntityCount, getEntityIdentifierAt, getFirstEntityIdentifier, getLastEntityIdentifier, getNextEntityIdentifier, getPreviousEntityIdentifier, isCacheEnabled, isCloneCachedEntities, refresh, refreshEntity, removeEntity, setCacheEnabled, setCloneCachedEntities, setEntityCacheMaxSize, updateEntity, updateEntityProperty, usesCache
 
Methods inherited from class com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider
addListener, fireEntityProviderChangeEvent, isFireEntityProviderChangeEvent, isTransactionsHandledByProvider, removeListener, setFireEntityProviderChangeEvents, setTransactionsHandledByProvider
 
Methods inherited from class com.vaadin.addon.jpacontainer.provider.LocalEntityProvider
addPrimaryKeyToSortList, createFilteredQuery, createSiblingQuery, createUnsortedFilteredQuery, detachEntity, doContainsEntity, doGetAllEntityIdentifiers, doGetEntity, doGetEntityCount, doGetEntityIdentifierAt, doGetEntityManager, doGetFirstEntityIdentifier, doGetLastEntityIdentifier, doGetNextEntityIdentifier, doGetPreviousEntityIdentifier, getEntityClassMetadata, getEntityManagerProvider, getIdentifier, getLazyLoadingDelegate, getQueryModifierDelegate, getSibling, readResolve, 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, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, refresh, refreshEntity, setEntitiesDetached, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegate
 
Methods inherited from interface com.vaadin.addon.jpacontainer.CachingEntityProvider
setEntitiesDetached
 

Constructor Detail

CachingMutableEntityProvider

public CachingMutableEntityProvider(Class<T> entityClass)

CachingMutableEntityProvider

public CachingMutableEntityProvider(Class<T> entityClass,
                                    JndiAddresses jndiAddresses)
Method Detail

isEntitiesDetached

public boolean isEntitiesDetached()
Description copied from interface: EntityProvider
If this method returns true, all entities returned from this entity provider are explicitly detached from the persistence context before returned, regardless of whether the persistence context is extended or transaction-scoped. Thus, no lazy-loaded associations will work and any changes made to the entities will not be reflected in the persistence context unless the entity is merged.

If this method returns false, the entities returned may be managed or detached, depending on the scope of the persistence context.

The default value is implementation specific.

Specified by:
isEntitiesDetached in interface CachingEntityProvider<T>
Specified by:
isEntitiesDetached in interface EntityProvider<T>
Overrides:
isEntitiesDetached in class CachingMutableLocalEntityProvider<T>
Returns:
true if the entities are explicitly detached, false otherwise.
See Also:
EntityProvider.setEntitiesDetached(boolean)

runInTransaction

protected void runInTransaction(Runnable operation)
Description copied from class: MutableLocalEntityProvider
If MutableLocalEntityProvider.isTransactionsHandledByProvider() is true, operation will be executed inside a transaction that is commited after the operation is completed. Otherwise, operation will just be executed.

Overrides:
runInTransaction in class MutableLocalEntityProvider<T>
Parameters:
operation - the operation to run (must not be null).

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Description copied from class: LocalEntityProvider
Gets the entity manager. If no entity manager has been set, the one returned by the registered entity manager provider is returned.

Specified by:
getEntityManager in interface EntityProvider<T>
Overrides:
getEntityManager in class LocalEntityProvider<T>
Returns:
the entity manager.

setJndiAddresses

public void setJndiAddresses(JndiAddresses addresses)
Specified by:
setJndiAddresses in interface JndiJtaProvider<T>
Parameters:
addresses - JNDI addresses that the provider should uses to lookup UserTransaction and EntityManager

getJndiAddresses

public JndiAddresses getJndiAddresses()
Specified by:
getJndiAddresses in interface JndiJtaProvider<T>
Returns:
settings that are used for JNDI lookups for UserTransaction and EntityManager


Copyright © 2013 Vaadin Ltd. All rights reserved.