|
IBM WebSphere Extended Deployment (XD)TM, Release 6.1 ObjectGrid API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface EntityManager
An EntityManager allows transactional introspection and manipulation of entities.
Each EntityManager is associated with an ObjectGrid Session. Use
the Session.getEntityManager() method to retrieve the Session's
EntityManager instance. Simultaneous interaction with the EntityManager and the owning
ObjectGrid Session is allowed.
All interactions with the EntityManager must be from a single thread. Multi-thread access to the EntityManager is not supported.
The EntityManager manages each entity within it's context scope. Entity operations will not be synchronized to the underlying ObjectGrid cache until the transaction is committed or the EntityManager context is flushed to the cache.
Each entity is backed by an ObjectGrid map with the same name as the entity and utilizes the
inherent map configuration for locking, evicting, indexing and synchronizing with a loader.
See BackingMap for details on how entity a map can
be configured and optimized for each entity.
The EntityManager converts each entity instance to key and value Tuple instances using
the entity's persistent fields or properties and stores the Tuples in the entity's associated
ObjectMap. The metadata that describes the Tuple can
be accessed using the ObjectMap.getEntityMetadata() or
BackingMap.getEntityMetadata() methods.
Accessing entities and Tuples simultaneously in a single transaction is not supported and may cause unexpected results.
Tuple,
EntityMetadata| Method Summary | |
|---|---|
void |
clear()
Clear the EntityManager's context. |
Query |
createQuery(java.lang.String qlString)
Create a Query instance for executing an ObjectGrid query language statement. |
java.lang.Object |
find(java.lang.Class entityClass,
java.lang.Object primaryKey)
Find an entity by primary key in the ObjectGrid cache. |
java.lang.Object |
findForUpdate(java.lang.Class entityClass,
java.lang.Object primaryKey)
Find an entity by primary key with the intent to be updated. |
void |
flush()
Synchronize the EntityManager to the ObjectGrid cache. |
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the EntityManager's context. |
EntityTransaction |
getTransaction()
Return the resource-level transaction object. |
void |
persist(java.lang.Object entity)
Make an entity instance managed and persistent in the ObjectGrid cache. |
void |
remove(java.lang.Object entity)
Remove the entity instance from the ObjectGrid cache. |
void |
setFlushMode(FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the EntityManager's context. |
| Method Detail |
|---|
void persist(java.lang.Object entity)
entity - the entity object instance to make persistent.
EntityExistsException - if the entity already exists. (The EntityExistsException may be thrown when the persist operation is
invoked, or the EntityExistsException or another PersistenceException may be thrown at flush or
commit time.)
java.lang.IllegalArgumentException - if not a valid entity
TransactionRequiredException - if invoked without an active transaction.ObjectMap.insert(Object, Object)void remove(java.lang.Object entity)
entity - the managed entity instance to remove from the ObjectGrid cache.
java.lang.IllegalArgumentException - if instance is not an entity or is a detached entity
TransactionRequiredException - if invoked without an active transaction.ObjectMap.remove(Object)
java.lang.Object find(java.lang.Class entityClass,
java.lang.Object primaryKey)
entityClass - the class representing the entity to find.primaryKey - an object instance representing the key of the entity to find. The key may be a single
Object (for single value keys), an IdClass or Entity instance (for composite keys)
or a Tuple instance.
java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the second argument is not a valid type for
that entity's primary keyTuple,
ObjectMap.get(Object)
java.lang.Object findForUpdate(java.lang.Class entityClass,
java.lang.Object primaryKey)
If the underlying map is configured with pessimistic locking strategy, an upgradeable
lock mode is obtained for this entity instance's map entry.
Any associated entities that are loaded are not locked for update. If the associates
are need to be locked in the same manner, then findForUpdate should be
called for each associated entity.
entityClass - the class representing the entity to find.primaryKey - an object instance representing the key of the entity to find.
java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the second argument is not a valid type for
that entity's primary keyObjectMap.getForUpdate(Object)void flush()
All managed entities in the current transaction are synchronized with the ObjectGrid cache and the associated ObjectGrid session is flushed.
TransactionRequiredException - if there is no transaction
PersistenceException - if the flush failsSession.flush()void setFlushMode(FlushModeType flushMode)
flushMode - the FlushModeType.FlushModeType getFlushMode()
EntityTransaction getTransaction()
Query createQuery(java.lang.String qlString)
When security is enabled, this method requires an com.ibm.websphere.objectgrid.security.ObjectGridPermission with action "query".
qlString - an ObjectGrid query string
java.lang.IllegalArgumentException - if query string is not validvoid clear()
Causes all managed entities to become detached. Any changes made to entities that have not been flushed to the cache will not be persisted.
|
IBM WebSphere Extended Deployment (XD)TM, Release 6.1 ObjectGrid API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||