Package com.oracle.coherence.jpa
Class JpaCacheLoader<K,V>
java.lang.Object
com.tangosol.util.Base
com.oracle.coherence.jpa.JpaCacheLoader<K,V>
- All Implemented Interfaces:
CacheLoader<K,
V>
- Direct Known Subclasses:
JpaCacheStore
JPA implementation of the
CacheLoader
interface.
Use this class as a load-only implementation that uses any JPA implementation to load entities from a data store. The entities must be mapped to the data store and a JPA persistence unit configuration must exist.
Use the JpaCacheStore
class for a full load and store implementation.
- Author:
- mlk 2007.04.20, jh 2007.05.18
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManagerFactory
The EntityManagerFactory from which EntityManager instances are obtained.protected Class
<?> The entity class that this CacheLoader is managing.protected String
Name of the entity that this CacheLoader is managing.Map of all shared entity manager factories for all persistence units. -
Constructor Summary
ConstructorsConstructorDescriptionJpaCacheLoader
(String sEntityName, String sEntityClassName, String sUnitName) Constructor which accepts an entity name, class name, and persistence unit name.JpaCacheLoader
(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 TypeMethodDescriptionprotected jakarta.persistence.EntityManager
Creates and returns an EntityManager.protected void
initialize
(String sEntityName, String sEntityClassName, String sUnitName, ClassLoader loader) Initialize this instance with the relevant metadata for the entity being stored.Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.loadAll
(Collection<? extends K> colKeys) Return the values associated with each the specified keys in the passed collection.Methods 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, wait
-
Field Details
-
s_mapFactories
Map of all shared entity manager factories for all persistence units. -
m_sEntityName
Name of the entity that this CacheLoader is managing. -
m_sEntityClass
The entity class that this CacheLoader is managing. -
m_emf
protected jakarta.persistence.EntityManagerFactory m_emfThe EntityManagerFactory from which EntityManager instances are obtained.
-
-
Constructor Details
-
JpaCacheLoader
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
-
JpaCacheLoader
public JpaCacheLoader(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
-
load
Description copied from interface:CacheLoader
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.- Specified by:
load
in interfaceCacheLoader<K,
V> - Parameters:
oKey
- key whose associated value is to be returned- Returns:
- the value associated with the specified key, or null if no value is available for that key
-
loadAll
Description copied from interface:CacheLoader
Return the values associated with each the specified keys in the passed collection. If a key does not have an associated value in the underlying store, then the return map will not have an entry for that key.The default implementation of this method calls
CacheLoader.load(K)
for each key in the supplied Collection. Implementations that can optimize multi-key operationsshould
override this default implementation.- Specified by:
loadAll
in interfaceCacheLoader<K,
V> - Parameters:
colKeys
- a collection of keys to load- Returns:
- a Map of keys to associated values for the specified keys
-
initialize
protected void initialize(String sEntityName, String sEntityClassName, String sUnitName, ClassLoader loader) Initialize this instance with the relevant metadata for the entity being stored.- 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
-
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()Creates and returns an EntityManager. A new instance is created each time this method is called.- Returns:
- a new EntityManager to use for a subsequent operation
-