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

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

Go to previous page
Previous
Go to next page
Next
View PDF

1 Introduction to Toplink Grid with Oracle Coherence

Oracle TopLink 11g Release 1 (11.1.1) enables you to scale out JPA applications using Oracle Coherence. TopLink Grid provides applications with a number of options on how they can scale, ranging from using Coherence as a distributed shared (L2) cache up to directing JP QL queries to Coherence for parallel execution across the grid to reduce database load. With TopLink Grid, you do not have to rewrite your applications to scale out. You can use your investment in JPA, and still take advantage of the scalability of Coherence.

TopLink Grid provides the following benefits:

This document describes how to:

This chapter contains the following sections:

1.1 Understanding TopLink Grid Integration

TopLink Grid integrates the TopLink JPA implementation (EclipseLink) with Oracle Coherence and provides two development approaches:

When integrating JPA applications with the Coherence data grid, note the potential benefits and restrictions. You must understand how the grid works and how it relates to your JPA configurations to realize the full potential.

See the following sections for information about TopLink Grid configuration options:

1.2 Entity Caching

By default, EclipseLink provides an EntityManagerFactory managed shared entity cache. This shared cache improves performance for multithreaded and Java EE server hosted applications running in a single JVM.

With TopLink Grid, you can replace the default EclipseLink shared (L2) cache with Oracle Coherence. This is known as Grid Cache configuration: the base configuration for TopLink Grid. This configuration applies the Coherence data grid to JPA applications that rely on database hosted data that cannot be entirely pre-loaded into a Coherence cache. You can define very large, shared grid caches that span cluster nodes. You do not have to add special configuration to ensure individual shared caches are coordinated. By defining a Grid Cache configuration for an entity in Coherence, all EntityManager.find() calls for that entity will result in a get call on the associated Coherence cache. If the Coherence cache does not contain the object, then the database is queried.

See "Grid Cache Configuration" for more information.

1.3 Reading and Querying Coherence Caches

In addition to Grid Cache configuration, you can configure TopLink Grid to direct read queries to Coherence. By configuring a TopLink JPA cache loader, even when there is no cache hit, the object can be read from the database and then placed in the cache, thereby making it available for subsequent queries. By managing very large numbers of objects, Coherence increases the likelihood of a cache hit, because read operations in one cluster member immediately make the object available to other members.

While using Coherence to spread an entity cache across the grid is useful, support for nonprimary key queries is especially beneficial. When you configure an entity in a Grid Read configuration, all read operations are directed to Coherence. JPQL queries are automatically translated into Coherence Filters and objects that match the filter are retrieved from the grid. Coherence executes all filters in parallel on each member of a cluster. This results in significantly faster processing for a query, compared to if all the objects resided in a single member. See "Grid Read Configuration" for more information.

Because filters apply only to objects in the Coherence cache, the configuration of a cache store or cache loader has no impact on ad hoc query processing. By default, queries are not executed against the database with this configuration. However, you can override this behavior by using the oracle.eclipselink.coherence.integrated.querying.IgnoreDefaultRedirector class to issue query hints. For example, the following hint directs the query to the database instead of to the Coherence cache:

query.setHint(QueryHints.QUERY_REDIRECTOR, new IgnoreDefaultRedirector());

For information about using EclipseLink JPA query hints, see the EclipseLink documentation at this URL:

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Use_EclipseLink_JPA_Query_Hints

1.4 Writing Entities to the Database

Another key configuration option is specifying how to write entities to the database. You can configure EclipseLink to do either of the following: