Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-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. <p/> 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. <p/> 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  Class m_sEntityClass
          The entity class that this CacheLoader is managing.
protected  String m_sEntityName
          Name of the entity that this CacheLoader is managing.
protected static Map s_mapFactories
          Map of all shared entity manager factories for all persistence units.

 

Constructor Summary
JpaCacheLoader(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
protected  javax.persistence.EntityManager getEntityManager()
          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.
 Object load(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.
 Map loadAll(Collection colKeys)
          Return the values associated with each the specified keys in the passed collection.

 

Field Detail

s_mapFactories

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

m_sEntityName

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

m_sEntityClass

protected 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(String sEntityName,
                      String sEntityClassName,
                      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(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 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 Object load(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 Map loadAll(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(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 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.6.0.0

E15725-01


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