com.sap.ip.me.api.persist.core
Interface PersistenceManager


public interface PersistenceManager

Provider for transactional services, such as object lifecycle management.

The Factory for PersistenceManager instances is the PersistenceRuntime.

Each persistence environment has to provide an implementation of interface PersistenceManager.

The implementation must map the calls and Exceptions defined in this interface to the persistence tools implementation of a persistence manager. This is most likely done via delegation.

Only one transaction at a time may be opened with beginTransaction(). If beginTransaction() is not explicitly called, the first write operation on the PersistenceManager will start the exclusive access to the storage. Read operations without beginTransaction() are prohibited and will throw PersistenceException

After commit() or rollback() no more operations can be executed on the calling instance. You have to request another instance from the PersistenceRuntime.

All persistent operations need to be specified with a TreeOptionType. It may have following values: SKELETON: only the entity itself is written

DEPENDENT: the entity itself and dependent associated entities are written

COMPLETE_TREE: the entity itself and all associated entities are written

Author:
SAP

Method Summary
 void beginTransaction(boolean doWait)
          Ensures exclusive access to persistent storage.
 void commit()
          Executes the changes on persistent storage and releases the Lock on persistence Operations for other PersistenceManagers.
 void delete(PersistableEntity entity, TreeOptionType treeOption)
          Deletes the given entity and dependent of the parameter treeOption the associated entities.
 void deleteAll(ClassDescriptor cdes, TreeOptionType treeOption)
          Deletes all Entities of the given ClassDescriptor
 boolean entityFactoryIsRegistered()
          Checks for registered EntityFactory
 JQueryResult executeQuery(JQuery query)
          Returns results for the Join Query, use default values for parameters
 JQueryResult executeQuery(JQuery query, int startIdx, int maxCount)
          Returns results for the Joun Query, use default values for parameters
 JQueryResult executeQuery(JQuery query, JQueryParameterSet params)
          Returns results for the Join Query
 JQueryResult executeQuery(JQuery query, JQueryParameterSet params, int startIdx, int maxCount)
          Returns results for the Joun Query
 PersistableEntity get(ClassDescriptor cdes, java.lang.String entityKey)
          Returns the Entity for given Entity Key and ClassDescriptor
 MeIterator get(Query query)
          Returns all entities for the query
 MeIterator getAll(ClassDescriptor cdes)
          Gets the all attribute of the PersistenceManager object
 int getCount(Query query)
          Returns the number of Results for the given Query
 PersistedObjectFactory getPersistedObjectFactory()
          Returns an instance of PersistedObjectFactory
 void insert(PersistableEntity entity, TreeOptionType treeOption)
          Description of the Method
 void modify(PersistableEntity entity, TreeOptionType treeOption)
          Modifies an entity instance and all belonging instances, depending on TreeOptionType and Entity dependencies.
 void registerEntityFactory(EntityFactory factory)
          Registers the EntityFactory to the PersistenceManger Instance
 void rollback()
          Reverts the changes on persistent storage and releases the Lock on persistence Operations for other PersistenceManagers After call of rollback() the PersistenceManager is unusable.
 void update(PersistableEntity entity, TreeOptionType treeOption)
          Inserts or modifies an entity instance, and all belonging instances, depending on TreeOptionType and Entity dependencies.
 

Method Detail

insert

public void insert(PersistableEntity entity,
                   TreeOptionType treeOption)
            throws PersistenceException
Description of the Method

Parameters:
entity - Description of the Parameter
treeOption - Description of the Parameter
Throws:
PersistenceException - Description of the Exception

update

public void update(PersistableEntity entity,
                   TreeOptionType treeOption)
            throws PersistenceException
Inserts or modifies an entity instance, and all belonging instances, depending on TreeOptionType and Entity dependencies.

Parameters:
entity - Description of the Parameter
treeOption - Description of the Parameter
Throws:
PersistenceException - Description of the Exception

modify

public void modify(PersistableEntity entity,
                   TreeOptionType treeOption)
            throws PersistenceException
Modifies an entity instance and all belonging instances, depending on TreeOptionType and Entity dependencies.

Parameters:
entity - Description of the Parameter
treeOption - Description of the Parameter
Throws:
PersistenceException - Description of the Exception

get

public PersistableEntity get(ClassDescriptor cdes,
                             java.lang.String entityKey)
                      throws PersistenceException
Returns the Entity for given Entity Key and ClassDescriptor

Parameters:
entityKey - Description of the Parameter
cdes - Description of the Parameter
Returns:
Description of the Return Value
Throws:
PersistenceException - Description of the Exception

executeQuery

public JQueryResult executeQuery(JQuery query,
                                 JQueryParameterSet params)
                          throws PersistenceException
Returns results for the Join Query

Parameters:
query - instance of com.sap.ip.me.api.persist.query.JQuery
params - Query Parameters
Returns:
Result Object with all matching Entities
Throws:
PersistenceException - I/O Errors
See Also:
JQuery, JQueryResult

executeQuery

public JQueryResult executeQuery(JQuery query,
                                 JQueryParameterSet params,
                                 int startIdx,
                                 int maxCount)
                          throws PersistenceException
Returns results for the Joun Query

Parameters:
query - instance of com.sap.ip.me.api.persist.query.JQuery
params - Query Parameters
startIdx - Offset for query execution
maxCount - Maximum number of results
Returns:
Result Object with all matching Entities
Throws:
PersistenceException - I/O Errors
See Also:
JQuery, JQueryResult

executeQuery

public JQueryResult executeQuery(JQuery query)
                          throws PersistenceException
Returns results for the Join Query, use default values for parameters

Parameters:
query - instance of com.sap.ip.me.api.persist.query.JQuery
Returns:
Result Object with all matching Entities
Throws:
PersistenceException - I/O Errors
See Also:
JQuery, JQueryResult

executeQuery

public JQueryResult executeQuery(JQuery query,
                                 int startIdx,
                                 int maxCount)
                          throws PersistenceException
Returns results for the Joun Query, use default values for parameters

Parameters:
query - instance of com.sap.ip.me.api.persist.query.JQuery
startIdx - Offset for query execution
maxCount - Maximum number of results
Returns:
Result Object with all matching Entities
Throws:
PersistenceException - I/O Errors
See Also:
JQuery, JQueryResult

get

public MeIterator get(Query query)
               throws PersistenceException
Returns all entities for the query

Parameters:
query - instance of com.sap.ip.api.persist.query.Query
Returns:
Iterator with all matching Entities
Throws:
PersistenceException - I/O Errors

getAll

public MeIterator getAll(ClassDescriptor cdes)
                  throws PersistenceException
Gets the all attribute of the PersistenceManager object

Parameters:
cdes - ClassDescriptor instance
Returns:
All Entities for given ClassDescriptor
Throws:
PersistenceException - I/O Errors

getCount

public int getCount(Query query)
             throws PersistenceException
Returns the number of Results for the given Query

Parameters:
query - instance of com.sap.ip.api.persist.query.Query
Returns:
number of matching Entities
Throws:
PersistenceException - I/O Errors

delete

public void delete(PersistableEntity entity,
                   TreeOptionType treeOption)
            throws PersistenceException
Deletes the given entity and dependent of the parameter treeOption the associated entities.

Parameters:
entity - instance of PersistableEntity
treeOption - operation depth
Throws:
PersistenceException

deleteAll

public void deleteAll(ClassDescriptor cdes,
                      TreeOptionType treeOption)
               throws PersistenceException
Deletes all Entities of the given ClassDescriptor

Parameters:
cdes - ClassDescriptor instance
treeOption - operation depth
Throws:
PersistenceException - I/O Errors

commit

public void commit()
            throws PersistenceException
Executes the changes on persistent storage and releases the Lock on persistence Operations for other PersistenceManagers.

After call of commit() the PersistenceManager is unusable. You have to call PersistenceRuntime.getPersistenceManager() to receive a new instance.

Throws:
PersistenceException - if commit() is called from a non Transaction owner.

rollback

public void rollback()
              throws PersistenceException
Reverts the changes on persistent storage and releases the Lock on persistence Operations for other PersistenceManagers

After call of rollback() the PersistenceManager is unusable. You have to call PersistenceRuntime.getPersistenceManager() to receive a new instance.

Throws:
PersistenceException - if rollback() is called from a non Transaction owner.

registerEntityFactory

public void registerEntityFactory(EntityFactory factory)
Registers the EntityFactory to the PersistenceManger Instance

Parameters:
factory - instance of EntityFactory

entityFactoryIsRegistered

public boolean entityFactoryIsRegistered()
Checks for registered EntityFactory

Returns:
true if EntityFactory is registered

getPersistedObjectFactory

public PersistedObjectFactory getPersistedObjectFactory()
Returns an instance of PersistedObjectFactory

Returns:
The persistedObjectFactory value

beginTransaction

public void beginTransaction(boolean doWait)
                      throws PersistenceException
Ensures exclusive access to persistent storage. It does not return a Transaction instance, but PersistenceManager himself has the functionality and behavior of a Transaction.

If beginTransaction() is not explicitly called, the first write operation on the PersistenceManager will start instance exclusive access. Read operations without beginTransaction() are prohibited and will throw PersistenceException

Parameters:
doWait - Specify whether the Manager waits to get persistence access or Exception is thrown
Throws:
PersistenceException - if a concurrent access is detected and doWait is set to false.


Copyright © 2005 SAP AG. All Rights Reserved.