Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.coherence.toplink
Class TopLinkCacheLoader

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.coherence.toplink.TopLinkCacheLoader

All Implemented Interfaces:
CacheLoader
Direct Known Subclasses:
TopLinkCacheStore

public class TopLinkCacheLoader
extends Base
implements CacheLoader

TopLink implementation of the CacheLoader interface.

Use this class as a load-only implementation that uses TopLink to load entities to and from a data store. The entities must be mapped to the data store and a TopLink session configuration or TopLink JPA persistence unit configuration must exist on the classpath.

Use the TopLinkCacheStore class for a full load and store implementation.

Author:
mlk 2007.04.20, jh 2005.05.18
See Also:
TopLinkCacheStore

Field Summary
protected  java.lang.Class m_clzEntity
          The entity class that this CacheLoader is managing.
protected  oracle.toplink.essentials.descriptors.ClassDescriptor m_descEntity
          Descriptor for entity class.
protected  boolean m_fUsePkClass
          Flag to indicate whether or not the PK is a composite class.
protected  oracle.toplink.essentials.mappings.DatabaseMapping m_mappingPk
          Database mapping of the PK attribute.
protected  java.lang.String m_sEntityName
          Name of the entity that this CacheLoader is managing.
protected  oracle.toplink.essentials.sessions.Session m_session
          Shared session for all entities.
protected  java.lang.String m_sPkField
          Field name of the PK attribute.

 

Constructor Summary
TopLinkCacheLoader(java.lang.String sEntityName)
          Constructor which accepts an entity name.
TopLinkCacheLoader(java.lang.String sEntityName, java.lang.String sSessionName)
          Constructor which accepts an entity name and session name.

 

Method Summary
protected  void initialize(java.lang.String sEntityName, java.lang.String sSessionName)
          Initialize the 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.
protected  java.lang.Object queryByPk(oracle.toplink.essentials.sessions.UnitOfWork uow, java.lang.Object oKey)
          Internal method to create and execute a "findByPK" query.
protected  java.lang.Object queryByPkCollection(oracle.toplink.essentials.sessions.UnitOfWork uow, java.util.Collection colPk)
          Internal method to create and execute a query to find in a group of PKs.

 

Field Detail

m_sEntityName

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

m_clzEntity

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

m_fUsePkClass

protected boolean m_fUsePkClass
Flag to indicate whether or not the PK is a composite class.

m_mappingPk

protected oracle.toplink.essentials.mappings.DatabaseMapping m_mappingPk
Database mapping of the PK attribute.

m_sPkField

protected java.lang.String m_sPkField
Field name of the PK attribute.

m_descEntity

protected oracle.toplink.essentials.descriptors.ClassDescriptor m_descEntity
Descriptor for entity class.

m_session

protected oracle.toplink.essentials.sessions.Session m_session
Shared session for all entities.

Constructor Detail

TopLinkCacheLoader

public TopLinkCacheLoader(java.lang.String sEntityName)
Constructor which accepts an entity name.
Parameters:
sEntityName - the alias for the persistent class

TopLinkCacheLoader

public TopLinkCacheLoader(java.lang.String sEntityName,
                          java.lang.String sSessionName)
Constructor which accepts an entity name and session name.
Parameters:
sEntityName - the alias for the persistent class
sSessionName - the name of the TopLink session (usually defined in sessions.xml)

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 sSessionName)
Initialize the instance with the relevant metadata for the entity being stored.
Parameters:
sEntityName - the alias for the persistent class
sSessionName - the name of the TopLink session

queryByPk

protected java.lang.Object queryByPk(oracle.toplink.essentials.sessions.UnitOfWork uow,
                                     java.lang.Object oKey)
Internal method to create and execute a "findByPK" query.
Parameters:
uow - the unit of work to use for the operation; if null use the session
oKey - the primary key to use to find the object
Returns:
the found object, or null if not found

queryByPkCollection

protected java.lang.Object queryByPkCollection(oracle.toplink.essentials.sessions.UnitOfWork uow,
                                               java.util.Collection colPk)
Internal method to create and execute a query to find in a group of PKs.

This method assumes that the entity has a simple PK and not a PK class, and the Collection passed in is one of simple PK value objects. This method should not be used when the entity has a PK class.

Parameters:
uow - the unit of work to use for the operation; if null use the session
colPk - the Collection of primary keys to use to find the entity instances
Returns:
the Collection of entities with a PK matching any of the specified PKs

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.