Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.coherence.jpa
Class JpaCacheStore

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

All Implemented Interfaces:
CacheLoader, CacheStore

public class JpaCacheStore
extends JpaCacheLoader
implements CacheStore

JPA implementation of the 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

Field Summary

 

Fields inherited from class com.tangosol.coherence.jpa.JpaCacheLoader
m_emf, m_sEntityClass, m_sEntityName, s_mapFactories

 

Constructor Summary
JpaCacheStore(java.lang.String sEntityName, java.lang.String sEntityClassName, java.lang.String sUnitName)
          Constructor which accepts an entity name, class name, and persistence unit name.
JpaCacheStore(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
 void erase(java.lang.Object oKey)
          Remove the specified key from the underlying store if present.
 void eraseAll(java.util.Collection colKeys)
          Remove the specified keys from the underlying store if present.
protected  void rollback(javax.persistence.EntityTransaction tx)
          Rollback the given EntityTransaction if it is not null and is active.
 void store(java.lang.Object oKey, java.lang.Object oValue)
          Store the specified value under the specified key in the underlying store.
 void storeAll(java.util.Map mapEntries)
          Store the specified values under the specified keys in the underlying store.

 

Methods inherited from class com.tangosol.coherence.jpa.JpaCacheLoader
getEntityManager, initialize, load, loadAll

 

Methods inherited from interface com.tangosol.net.cache.CacheLoader
load, loadAll

 

Constructor Detail

JpaCacheStore

public JpaCacheStore(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

JpaCacheStore

public JpaCacheStore(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

store

public void store(java.lang.Object oKey,
                  java.lang.Object oValue)
Store 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:
store in interface CacheStore
Parameters:
oKey - key to store the value under
oValue - value to be stored

storeAll

public void storeAll(java.util.Map mapEntries)
Store 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.

Specified by:
storeAll in interface CacheStore
Parameters:
mapEntries - a Map of any number of keys and values to store

erase

public void erase(java.lang.Object oKey)
Remove the specified key from the underlying store if present.
Specified by:
erase in interface CacheStore
Parameters:
oKey - key whose mapping is being removed from the cache

eraseAll

public void eraseAll(java.util.Collection colKeys)
Remove 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.

Specified by:
eraseAll in interface CacheStore
Parameters:
colKeys - keys whose mappings are being removed from the cache

rollback

protected void rollback(javax.persistence.EntityTransaction tx)
Rollback the given EntityTransaction if it is not null and is active.
Parameters:
tx - the EntityTransaction; may be null

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.