|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CachingEntityProvider<T>
Interface to be implemented by all EntityProviders that perform
some kind of internal caching.
| Method Summary | |
|---|---|
void |
flush()
Flushes the cache, forcing all entities to be loaded from the persistence storage upon next request. |
int |
getEntityCacheMaxSize()
Gets the maximum number of entity instances to store in the cache. |
boolean |
isCacheEnabled()
Returns whether the entity provider currently has the internal cache enabled. |
boolean |
isCloneCachedEntities()
Returns whether entities found in the cache should be cloned before they are returned or not. |
boolean |
isEntitiesDetached()
If the cache is in use, all entities are automatically detached regardless of the state of this flag. |
void |
setCacheEnabled(boolean cacheEnabled)
Turns the cache on or off. |
void |
setCloneCachedEntities(boolean clone)
Changes the value of the isCloneCachedEntities() flag. |
void |
setEntitiesDetached(boolean detached)
If the cache is in use, all entities are automatically detached regardless of the state of this flag. |
void |
setEntityCacheMaxSize(int maxSize)
Sets the maximum number of entity instances to store in the cache. |
boolean |
usesCache()
Returns whether the entity provider is currently using the internal cache, which will be the case if both the caching is enabled ( setCacheEnabled(boolean) and there is no filter modifiying
QueryModifierDelegate in use. |
| Methods inherited from interface com.vaadin.addon.jpacontainer.EntityProvider |
|---|
containsEntity, getAllEntityIdentifiers, getEntity, getEntityCount, getEntityIdentifierAt, getEntityManager, getEntityManagerProvider, getFirstEntityIdentifier, getIdentifier, getLastEntityIdentifier, getLazyLoadingDelegate, getNextEntityIdentifier, getPreviousEntityIdentifier, getQueryModifierDelegate, refresh, refreshEntity, setEntityManager, setEntityManagerProvider, setLazyLoadingDelegate, setQueryModifierDelegate |
| Method Detail |
|---|
int getEntityCacheMaxSize()
void setEntityCacheMaxSize(int maxSize)
throws UnsupportedOperationException
maxSize - the new maximum size, or -1 for unlimited size.
UnsupportedOperationException - if this implementation does not support configuring the
maximum cache size.void flush()
boolean isCacheEnabled()
QueryModifierDelegate is in use and it modifies
the filters through the
QueryModifierDelegate.filtersWillBeAdded(javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.CriteriaQuery, java.util.List)
method, caching will NOT be enabled.
void setCacheEnabled(boolean cacheEnabled)
throws UnsupportedOperationException
QueryModifierDelegate is in use and it modifies
the filters through the
QueryModifierDelegate.filtersWillBeAdded(javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.CriteriaQuery, java.util.List)
method, caching will NOT be enabled.
cacheEnabled - true to turn the cache on, false to turn it off.
UnsupportedOperationException - if the cache cannot be turned on or off programmatically.boolean usesCache()
setCacheEnabled(boolean) and there is no filter modifiying
QueryModifierDelegate in use.
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. 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.
isEntitiesDetached in interface EntityProvider<T>isCacheEnabled()
void setEntitiesDetached(boolean detached)
throws UnsupportedOperationException
Specifies whether the entities returned by the entity provider should be
explicitly detached or not. See EntityProvider.isEntitiesDetached() for a more
detailed description of the consequences.
setEntitiesDetached in interface EntityProvider<T>detached - true to request explicitly detached entities, false otherwise.
UnsupportedOperationException - if the implementation does not allow the user to change the
way entities are returned.isCacheEnabled()boolean isCloneCachedEntities()
#getEntity(java.lang.Object) with the same entity ID and without
flushing the cache in between may return the same entity instance. This
could be a problem if the instance is modified, as the cache would then
contain the locally modified entity instance and not the one that was
fetched from the persistence storage.
If the entity instances are serialized and deserialized before they reach the container, or the container is read-only, entities need not be cloned.
It is undefined what happens if this flag is true and the entities are not cloneable.
The default value of this flag is implementation dependent.
setCloneCachedEntities(boolean)
void setCloneCachedEntities(boolean clone)
throws UnsupportedOperationException
isCloneCachedEntities() flag.
clone - true to clone cached entities before returning them, false to
return them directly.
UnsupportedOperationException - if the implementation does not support changing the state of
this flag.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||