JPA persistence property Usage:
for all entities append DEFAULT suffix to CACHE_TYPE_ prefix:
properties.add(PersistenceUnitProperties.CACHE_TYPE_DEFAULT, CacheType.Weak);
for a single entity append either entity name or a full class name to CACHE_TYPE_ prefix:
properties.add(PersistenceUnitProperties.CACHE_TYPE_ + "Employee", CacheType.Weak);
properties.add(PersistenceUnitProperties.CACHE_TYPE_ + "my.test.Employee", CacheType.Weak);
Values are case-insensitive. "" could be used instead of default value CacheType.DEFAULT.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default cache type is SoftWeak.static final String
A Soft cache holds all objects read by the application.static final String
A HardWeak cache holds all objects in use by the application, and a fixed size sub-cache of MRU objects using normal (hard) references.static final String
NONE does not cache any objects.static final String
A Soft cache holds all objects read by the application, but allows any un-referenced objects to be free to garbage collection only when the JVM decides memory is low.static final String
A SoftWeak cache holds all objects in use by the application, and a fixed size sub-cache of MRU objects using Soft references.static final String
A Weak cache holds all objects in use by the application, but allows any un-referenced objects to be free to garbage collection. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.This constructor will be marked private and the class final. -
Method Summary
-
Field Details
-
Weak
A Weak cache holds all objects in use by the application, but allows any un-referenced objects to be free to garbage collection. This guarantees object identity, allows optimal garbage collection, but provides little caching benefit.- See Also:
-
Soft
A Soft cache holds all objects read by the application, but allows any un-referenced objects to be free to garbage collection only when the JVM decides memory is low. This guarantees object identity, allows garbage collection when memory is low, and provides optimal caching benefit.- See Also:
-
SoftWeak
A SoftWeak cache holds all objects in use by the application, and a fixed size sub-cache of MRU objects using Soft references. It allows any un-referenced objects not in the sub-cache to be free to garbage collection, and the objects in the sub-cache are free to garbage collect only when the JVM decides memory is low. This guarantees object identity, allows configurable garbage collection, and provides configurable caching benefit.- See Also:
-
HardWeak
A HardWeak cache holds all objects in use by the application, and a fixed size sub-cache of MRU objects using normal (hard) references. It allows any un-referenced objects not in the sub-cache to be free to garbage collection, but not objects in the sub-cache. This guarantees object identity, allows configurable garbage collection, and provides configurable caching benefit.- See Also:
-
Full
A Soft cache holds all objects read by the application. It does not allow any garbage collection. * This guarantees object identity, allows no garbage collection, and provides complete caching benefit.WARNING: This cache type should only be used for a fixed sized number of objects, otherwise it will lead to an eventual memory leak.
- See Also:
-
NONE
NONE does not cache any objects. It allows any un-referenced objects to be free to garbage collection. This provides no object identity, allows complete garbage collection, and provides no caching benefit.WARNING: This cache type should normally not be used. Instead disable the share cache through PersistenceUnitProperties.CACHE_SHARED_. Lack of object identity can lead to infinite loops for objects that have circular references and no indirection.
- See Also:
-
DEFAULT
The default cache type is SoftWeak.- See Also:
-
-
Constructor Details
-
CacheType
Deprecated, for removal: This API element is subject to removal in a future version.This constructor will be marked private and the class final. It is not designed for extensibility.
-