Class JpaCacheStore<K,V>
- All Implemented Interfaces:
CacheLoader<K,,V> CacheStore<K,V>
CacheStore interface.
Use this class as a full load and store implementation that uses any JPA implementation to load and store entities to and from a data store. The entities must be mapped to the data store and a JPA persistence unit configuration must exist.
NOTE: The persistence unit is assumed to be set to use RESOURCE_LOCAL transactions.
- Author:
- mlk 2007.04.20, jh 2007.05.18
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter -
Field Summary
Fields inherited from class com.oracle.coherence.jpa.JpaCacheLoader
m_emf, m_sEntityClass, m_sEntityName, s_mapFactories -
Constructor Summary
ConstructorsConstructorDescriptionJpaCacheStore(String sEntityName, String sEntityClassName, String sUnitName) Constructor which accepts an entity name, class name, and persistence unit name.JpaCacheStore(String sEntityName, String sEntityClassName, String sUnitName, ClassLoader loader) Constructor which accepts an entity name, class name, persistence unit name, and classloader. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemove the specified key from the underlying store if present.voideraseAll(Collection<? extends K> colKeys) Remove the specified keys from the underlying store if present.protected voidrollback(jakarta.persistence.EntityTransaction tx) Rollback the given EntityTransaction if it is not null and is active.voidStore the specified value under the specified key in the underlying store.voidStore the specified values under the specified keys in the underlying store.Methods inherited from class com.oracle.coherence.jpa.JpaCacheLoader
getEntityManager, initialize, load, loadAllMethods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, waitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tangosol.net.cache.CacheLoader
load, loadAll
-
Constructor Details
-
JpaCacheStore
Constructor which accepts an entity name, class name, and persistence unit name.- Parameters:
sEntityName- the JPA name of the entitysEntityClassName- the fully-qualified class name of the entitysUnitName- the name of the persistence unit
-
JpaCacheStore
public JpaCacheStore(String sEntityName, String sEntityClassName, String sUnitName, ClassLoader loader) Constructor which accepts an entity name, class name, persistence unit name, and classloader.- Parameters:
sEntityName- the JPA name of the entitysEntityClassName- the fully-qualified class name of the entitysUnitName- the name of the persistence unitloader- the ClassLoader used to load the entity class
-
-
Method Details
-
store
Description copied from interface:CacheStoreStore the specified value under the specified key in the underlying store. This method is intended to support both key/value creation and value update for a specific key.- Specified by:
storein interfaceCacheStore<K,V> - Parameters:
oKey- key to store the value underoValue- value to be stored
-
storeAll
Description copied from interface:CacheStoreStore the specified values under the specified keys in the underlying store. This method is intended to support both key/value creation and value update for the specified keys.If this operation fails (by throwing an exception) after a partial success, the convention is that entries which have been stored successfully are to be removed from the specified mapEntries, indicating that the store operation for the entries left in the map has failed or has not been attempted.
The default implementation of this method calls
CacheStore.store(K, V)for each entry in the supplied Map. Once stored successfully, an entry is removed from the Map (if possible). Implementations that can optimize multi-entry operationsshouldoverride this default implementation.- Specified by:
storeAllin interfaceCacheStore<K,V> - Parameters:
mapEntries- a Map of any number of keys and values to store
-
erase
Description copied from interface:CacheStoreRemove the specified key from the underlying store if present.- Specified by:
erasein interfaceCacheStore<K,V> - Parameters:
oKey- key whose mapping is being removed from the cache
-
eraseAll
Description copied from interface:CacheStoreRemove the specified keys from the underlying store if present.If this operation fails (by throwing an exception) after a partial success, the convention is that keys which have been erased successfully are to be removed from the specified colKeys, indicating that the erase operation for the keys left in the collection has failed or has not been attempted.
The default implementation of this method calls
CacheStore.erase(K)for each key in the supplied Collection. Once erased successfully, the key is removed from the Collection (if possible). Implementations that can optimize multi-key operationsshouldoverride this default implementation.- Specified by:
eraseAllin interfaceCacheStore<K,V> - Parameters:
colKeys- keys whose mappings are being removed from the cache
-
rollback
protected void rollback(jakarta.persistence.EntityTransaction tx) Rollback the given EntityTransaction if it is not null and is active.- Parameters:
tx- the EntityTransaction; may be null
-