Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.coherence.jpa
Class JpaCacheLoader

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.coherence.jpa.JpaCacheLoader

All Implemented Interfaces:
CacheLoader
Direct Known Subclasses:
JpaCacheStore

public class JpaCacheLoader
extends Base
implements CacheLoader

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:
JpaCacheStore

Field Summary
protected  javax.persistence.EntityManagerFactory m_emf
          The EntityManagerFactory from which EntityManager instances are obtained.
protected  java.lang.Class m_sEntityClass
          The entity class that this CacheLoader is managing.
protected  java.lang.String m_sEntityName
          Name of the entity that this CacheLoader is managing.
protected static java.util.Map s_mapFactories
          Map of all shared entity manager factories for all persistence units.

 

Constructor Summary
JpaCacheLoader(java.lang.String sEntityName, java.lang.String sEntityClassName, java.lang.String sUnitName)
          Constructor which accepts an entity name, class name, and persistence unit name.
JpaCacheLoader(java.lang.String sEntityName, java.lang.String sEntityClassName, java.lang.String sUnitName, java.lang.ClassLoader loader)
          Constructor which accepts an entity name, class name, persistence unit name, and classloader.

 

Method Summary
protected  javax.persistence.EntityManager getEntityManager()
          Creates and returns an EntityManager.
protected  void initialize(java.lang.String sEntityName, java.lang.String sEntityClassName, java.lang.String sUnitName, java.lang.ClassLoader loader)
          Initialize this instance with the relevant metadata for the entity being stored.
 java.lang.Object load(java.lang.Object oKey)
          Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
 java.util.Map loadAll(java.util.Collection colKeys)
          Return the values associated with each the specified keys in the passed collection.

 

Field Detail

s_mapFactories

protected static final java.util.Map s_mapFactories
Map of all shared entity manager factories for all persistence units.

m_sEntityName

protected java.lang.String m_sEntityName
Name of the entity that this CacheLoader is managing.

m_sEntityClass

protected java.lang.Class m_sEntityClass
The entity class that this CacheLoader is managing.

m_emf

protected javax.persistence.EntityManagerFactory m_emf
The EntityManagerFactory from which EntityManager instances are obtained.

Constructor Detail

JpaCacheLoader

public JpaCacheLoader(java.lang.String sEntityName,
                      java.lang.String sEntityClassName,
                      java.lang.String sUnitName)
Constructor which accepts an entity name, class name, and persistence unit name.
Parameters:
sEntityName - the JPA name of the entity
sEntityClassName - the fully-qualified class name of the entity
sUnitName - the name of the persistence unit

JpaCacheLoader

public JpaCacheLoader(java.lang.String sEntityName,
                      java.lang.String sEntityClassName,
                      java.lang.String sUnitName,
                      java.lang.ClassLoader loader)
Constructor which accepts an entity name, class name, persistence unit name, and classloader.
Parameters:
sEntityName - the JPA name of the entity
sEntityClassName - the fully-qualified class name of the entity
sUnitName - the name of the persistence unit
loader - the ClassLoader used to load the entity class

Method Detail

load

public java.lang.Object load(java.lang.Object oKey)
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 interface CacheLoader
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

public java.util.Map loadAll(java.util.Collection colKeys)
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.
Specified by:
loadAll in interface CacheLoader
Parameters:
colKeys - a collection of keys to load
Returns:
a Map of keys to associated values for the specified keys

initialize

protected void initialize(java.lang.String sEntityName,
                          java.lang.String sEntityClassName,
                          java.lang.String sUnitName,
                          java.lang.ClassLoader loader)
Initialize this instance with the relevant metadata for the entity being stored.
Parameters:
sEntityName - the JPA name of the entity
sEntityClassName - the fully-qualified class name of the entity
sUnitName - the name of the persistence unit
loader - the ClassLoader used to load the entity class

getEntityManager

protected javax.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

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.