WebSphere eXtreme Scale Product Overview > Cache integration > Use eXtreme Scale with JPA


JPA Loaders overview


You can use a Java Persistence API (JPA) loader plug-in implementation with eXtreme Scale to interact with any database supported by the chosen loader.

The plug-ins...

...are used to synchronize the ObjectGrid maps with a database.

You must have a JPA implementation, such as Hibernate or OpenJPA, to use this feature. The database can be any back end that is supported by the chosen JPA provider.

You can use the JPALoader plug-in when you are storing data using the ObjectMap API. Use the JPAEntityLoader plug-in when you are storing data using the EntityManager API.


JPA loader architecture

The JPA Loader is used for eXtreme Scale maps that store plain old Java objects (POJO).

Figure 1. JPA Loader architecture

JPA loader architecture

When an ObjectMap.get(Object key) method is called, the eXtreme Scale run time first checks whether the entry is contained in the ObjectMap layer. If not, the run time delegates the request to the JPA Loader. Upon request of loading the key, the JPALoader calls the JPA EntityManager.find(Object key) method to find the data from the JPA layer. If the data is contained in the JPA entity manager, it is returned; otherwise, the JPA provider interacts with the database to get the value.

When an update to ObjectMap occurs, for example, using the ObjectMap.update(Object key, Object value) method, the eXtreme Scale run time creates a LogElement for this update and sends it to the JPALoader. The JPALoader calls the JPA EntityManager.merge(Object value) method to update the value to the database.

For the JPAEntityLoader, the same four layers are involved. However, because the JPAEntityLoader plug-in is used for maps that store eXtreme Scale entities, relations among entities could complicate the usage scenario. An eXtreme Scale entity is distinguished from JPA entity.


Methods

Loaders provide three main methods:

get Returns a list of values that correspond to the list of keys that are passed in by retrieving the data using JPA.

The method uses JPA to find the entities in the database. For the JPALoader plug-in, the returned list contains a list of JPA entities directly from the find operation. For the JPAEntityLoader plug-in, the returned list contains eXtreme Scale entity value tuples that are converted from the JPA entities.

batchUpdate Writes the data from ObjectGrid maps to the database.

Depending on different operation types (insert, update, or delete), the loader uses the JPA persist, merge, and remove operations to update the data to the database. For the JPALoader, the objects in the map are directly used as JPA entities. For the JPAEntityLoader, the entity tuples in the map are converted into objects which are used as JPA entities.

preloadMap Preloads the map using the ClientLoader.load client loader method.

For partitioned maps, the preloadMap method is only called in one partition. The partition is specified the preloadPartition property of the JPALoader or JPAEntityLoader class.

If the preloadPartition value is set to less than zero, or greater than (total_number_of_partitions - 1), preload is disabled.

Both JPALoader and JPAEntityLoader plug-ins work with the JPATxCallback class to coordinate the eXtreme Scale transactions and JPA transactions. JPATxCallback must be configured in the ObjectGrid instance to use these two loaders.


Configuration and programming

For more information, see...



Parent topic

Use eXtreme Scale with JPA


+

Search Tips   |   Advanced Search