|
IBM WebSphereTM eXtreme Scale, Release 8.6 API Specification |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.websphere.objectgrid.jpa.JPALoader com.ibm.websphere.objectgrid.jpa.JPAEntityLoader
public class JPAEntityLoader
This is the entity loader that uses Java Persistence API (JPA) to load and store data in the "database". Therefore, a JPA provider is required to use this feature. The "database" here can be any backend supported by the chosen JPA provider.
A TransactionCallback plugin, JPATxCallback
,
should be configured on the ObjectGrid to provide the transaction
coordination between the ObjectGrid transaction and the JPA entity manager
transaction for this loader to work.
A JPA persistence unit name and entity class name are required to use JPA. The persistence unit name is provided to the JPATxCallback instance and the entity class name is provided to this loader. This establishes a one to one relation between ObjectGrid instances and JPA persistence units and a one to one relation between ObjectGrid maps and JPA entities.
When defining the ObjectGrid entity metadata for the entity map, an ObjectGrid entity class has already been defined. If the JPA entity class is the same as this ObjectGrid entity class, there is no need to provide the entity class any more. If the JPA entity class is different, it is required to be set using the attribute "entityClassName".
This loader is used for ObjectGrid entity maps only.
Use JPALoader
for ObjectGrid maps that store POJOs.
If entities have relationships to other entities, each entity map must have an independent JPAEntityLoader. The JPAEntityLoader cannot be used to load the root entity and its children.
If the preloadPartition property is set to a valid partition, the preloadMap method will preload all the data
into the ObjectGrid maps from that partition. The preloadMap uses ClientLoader
to preload a map. By default, the preloadPartition is set to -1 to disable the map preload.
This JPAEntityLoader implements the RetryableLoader because it can handle a retry record
from ObjectGrid.
When the retry indication slot contains a Boolean.TRUE
, the JPAEntityLoader handles the
ObjectGrid log elements in the following ways:
- For an insert or update type log element, it calls
EntityManager.merge(Object)
method to merge the entity.
- For a delete type log element, if calls
EntityManager.find(Class, Object)
method to find the entity. If the
entity is found, it calls EntityManager.remove(Object)
method to remove it.
- Since:
- WAS XD 6.1.0.3
- See Also:
ClientLoader
Nested Class Summary
Nested classes/interfaces inherited from interface com.ibm.websphere.objectgrid.plugins.Loader
Loader.SpecialValue
Field Summary
Fields inherited from class com.ibm.websphere.objectgrid.jpa.JPALoader
entityClass, entityClassName, mapName, ogName, preloadPartition, retryIndicationSlot, txCallback
Fields inherited from interface com.ibm.websphere.objectgrid.plugins.Loader
KEY_NOT_FOUND
Constructor Summary
JPAEntityLoader()
Method Summary
void
batchUpdate(TxID txid,
LogSequence sequence)
Write the data from ObjectGrid entity maps to JPA.
List
get(TxID tx,
List keys,
boolean forUpdate)
Returns the list of values corresponding to the set of keys passed in by
retrieving the data using JPA.
protected void
initialize(ObjectGrid grid,
BackingMap bmap)
Methods inherited from class com.ibm.websphere.objectgrid.jpa.JPALoader
getEntityClassName, getPreloadPartition, getTxCallback, preloadMap, setEntityClassName, setPreloadPartition, setRetryIndicationSlot
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
JPAEntityLoader
public JPAEntityLoader()
Method Detail
batchUpdate
public void batchUpdate(TxID txid,
LogSequence sequence)
throws LoaderException,
OptimisticCollisionException
- Write the data from ObjectGrid entity maps to JPA.
The LogSequence contains a sequence of log elements which contain entity key and value tuples.
These tuples are converted in to JPA POJO entities, which are then used to interact with JPA to
insert, update, or remove the JPA entities.
- Specified by:
batchUpdate
in interface Loader
- Overrides:
batchUpdate
in class JPALoader
- Parameters:
txid
- the transaction id objectsequence
- the set of changes being applied to this object's map
- Throws:
LoaderException
- if an error occurs during processing of this method
OptimisticCollisionException
- if a version mismatch is detected- See Also:
Loader.batchUpdate(TxID, LogSequence)
get
public List get(TxID tx,
List keys,
boolean forUpdate)
throws LoaderException
- Returns the list of values corresponding to the set of keys passed in by
retrieving the data using JPA.
The data retrieved from JPA are POJO entities, which are then converted into
ObjectGrid entity tuples. Each key provided will have a corresponding entity
tuple in the returned list.
- Specified by:
get
in interface Loader
- Overrides:
get
in class JPALoader
- Parameters:
tx
- the transaction ID objectkeys
- List of keysforUpdate
- true
when a getForUpdate method is called.
This parameter can be used to do a "SELECT for UPDATE"
invocation for proper database locking.
JPA as a result of JPA find operation.
- Returns:
- List of Object values
- Throws:
LoaderException
- if an error occurs during processing of this method- See Also:
Loader.get(TxID, List, boolean)
initialize
protected void initialize(ObjectGrid grid,
BackingMap bmap)
throws LoaderException
- Throws:
LoaderException
Overview
Package
Class
Tree
Serialized
Deprecated
Index
Help
IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
© Copyright International Business Machines Corp 2005,2012. All rights reserved.