|
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
public class JPALoader
This is the 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. Otherwise, a LoaderException will be thrown.
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.
This loader is used for ObjectGrid maps that store POJO only.
Use JPAEntityLoader
for ObjectGrid maps that store ObjectGrid entities.
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 JPALoader implements the RetryableLoader because it can handle a retry record from ObjectGrid.
When the retry indication slot contains a Boolean.TRUE
, the JPALoader handles the
ObjectGrid log elements in the following ways:
EntityManager.merge(Object)
method to merge the entity. EntityManager.find(Class, Object)
method to find the entity. If the
entity is found, it calls EntityManager.remove(Object)
method to remove it.
ClientLoader
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.ibm.websphere.objectgrid.plugins.Loader |
---|
Loader.SpecialValue |
Field Summary | |
---|---|
protected Class |
entityClass
|
protected String |
entityClassName
|
protected String |
mapName
|
protected String |
ogName
|
protected int |
preloadPartition
|
protected int |
retryIndicationSlot
|
protected JPATxCallback |
txCallback
|
Fields inherited from interface com.ibm.websphere.objectgrid.plugins.Loader |
---|
KEY_NOT_FOUND |
Constructor Summary | |
---|---|
JPALoader()
Default constructor |
Method Summary | |
---|---|
void |
batchUpdate(TxID txid,
LogSequence sequence)
Write the data from ObjectGrid entity maps to JPA. |
List |
get(TxID txid,
List keyList,
boolean forUpdate)
Returns the list of values corresponding to the set of keys passed in by retrieving the data using JPA. |
String |
getEntityClassName()
Retrieve the JPA entity class name that should be loaded. |
int |
getPreloadPartition()
|
JPATxCallback |
getTxCallback()
Retrieve the JPA transaction callback instance. |
void |
preloadMap(Session session,
BackingMap backingMap)
This method initializes the loader and preloads the map using the ClientLoader.load(ObjectGrid, String, String, Map, Class, String, Map, boolean, ClientLoadCallback)
method. |
void |
setEntityClassName(String entityClassName)
Set the name of the JPA entity class to load. |
void |
setPreloadPartition(int preloadPartition)
Specify the partition at which the map preload will be launched. |
void |
setRetryIndicationSlot(int slotNumber)
set the slot number which contains whether the batch update from ObjectGrid is a retry of previous transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected JPATxCallback txCallback
protected String entityClassName
protected Class entityClass
protected int preloadPartition
protected int retryIndicationSlot
protected String ogName
protected String mapName
Constructor Detail |
---|
public JPALoader()
Method Detail |
---|
public void setRetryIndicationSlot(int slotNumber)
RetryableLoader
TxID.getSlot(int)
method. If the slot contains a Boolean.TRUE object, then
the log sequence is a retry sequence. If the slot contains a null object or a Boolean.FALSE,
then the log sequence is not a retry sequence.
setRetryIndicationSlot
in interface RetryableLoader
slotNumber
- the slot numberpublic void batchUpdate(TxID txid, LogSequence sequence) throws LoaderException, OptimisticCollisionException
The LogSequence contains a sequence of log elements which contain keys and values. These keys are values are used to interact with JPA to insert, update, or merge a JPA entity.
batchUpdate
in interface Loader
txid
- the transaction id objectsequence
- the set of changes being applied to this object's map
LoaderException
- if an error occurs during processing of this method
OptimisticCollisionException
- if a version mismatch is detectedLoader.batchUpdate(TxID, LogSequence)
public List get(TxID txid, List keyList, boolean forUpdate) throws LoaderException
get
in interface Loader
txid
- the transaction ID objectkeyList
- 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.
LoaderException
- if an error occurs during processing of this methodLoader.get(TxID, List, boolean)
public void preloadMap(Session session, BackingMap backingMap) throws LoaderException
ClientLoader.load(ObjectGrid, String, String, Map, Class, String, Map, boolean, ClientLoadCallback)
method. The persistence unit name and persistence property map are retrieved from the
JPATxCallback
TransactionCallback instance configured on the ObjectGrid.
For partition maps, the preload will only be called in one partition, which is specified by users using the preloadPartition property. If the preloadPartition value is set to less than 0, or greater than totalNumberOfPartition -1, no preload will happen.
preloadMap
in interface Loader
session
- a Session
reference to use for demarcating transactions.backingMap
- the BackingMap
this object is associated with
LoaderException
- if an error occurs during processing of this method
Since the default value of preloadPartition is -1, the map will not be preloaded by default.
LoaderException
- if a JPATxCallback
is not configured.
Loader.preloadMap(Session, BackingMap)
public int getPreloadPartition()
public void setPreloadPartition(int preloadPartition)
The default value of preloadPartition is -1. Therefore, by default, map preload will not be launched.
preloadPartition
- The preloadPartition to set.public String getEntityClassName()
public void setEntityClassName(String entityClassName)
entityClassName
- the JPA entity class name to set.
IllegalArgumentException
- if the entity class name cannot be foundpublic JPATxCallback getTxCallback()
JPATxCallback.getEntityManager(TxID)
|
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 |