Skip Headers
Oracle® Fusion Middleware Integration Guide for Oracle TopLink with Coherence Gird
11g Release 1 (11.1.1)

Part Number E16596-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

"Traditional Coherence" Configuration

This section includes information on the CacheStore/CacheLoader configuration.


The TopLink Grid CacheStore/CacheLoader configuration allows you to map classes using JPA, but use the Coherence API to interact with the Coherence cache. This allows Coherence to interact with the database.

You can also use asynchronous writing with the CacheStore/CacheLoader configuration, by using the Coherence "write behind" configuration.

In general:

  • Through a CacheLoader, all read operations get objects from the database. See "Reading Objects".

  • Through a CacheLoader, all write operations update the database. See "Writing Objects".

See "Examples" for detailed examples.

Reading Objects

In the Coherence CacheStore/CacheLoader, all read queries are directed to the database by the TopLink CacheLoader.

This figure illustrates a query in the Grid Read configuration:

  1. Application issues a get query.

  2. By using a CacheLoader, Coherence will load the from TopLink.

  3. TopLink will query the database.

Writing Objects

In the Coherence CacheStore/CacheLoader, TopLink performs all database writes (insert, update, delete) through the CacheStore.

This figure illustrates a query in the Grid Read configuration:

  1. Application issues a put query.

  2. By using a CacheStore, Coherence will store the from TopLink.

  3. TopLink will insert the object into the database.


In the cache configuration (coherence-cache-config.xml) define the cache, as shown in this example.

Example 1 Configuring the Cache

            <local-scheme />
            Define the cache scheme 
              Since the client code is using Coherence API we need the "standalone" version of the cache loader 

In Example 2, you set the employee information and add the new object to Coherence. This issues an INSERT to the CacheStore.

Example 2 Inserting Objects

Employee employee = new Employee();
// Putting a new object into Coherence  will result in an INSERT in the CacheStore 
employeeCache.put(NEW_EMP_ID, employee);

Getting an object from the cache produces no SQL statements. Getting an object that is not in the cache produces a SELECT statement.

Example 3 Reading Objects

// Getting an object from cache produces no SQL
System.out.println("New Employee from cache is: " + employeeCache.get(NEW_EMP_ID));

// Getting an object not in cache will produce a SELECT in the CacheStore
System.out.println("Non-existant Employee from cache is: " + employeeCache.get(NON_EXISTANT_EMP_ID));