|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Persistence
The persistence engine implements this interface in order to allow objects to be created, removed, loaded, stored, locked and checked for dirtyness.
The caller takes full responsibility to assure integrity of transactions and object caching and only relies on the engine to assist in assuring that through the mechanisms available to it.
All method calls provide an open connection into the persistence storage. The connection is opened by and maintained in the context of a transaction. The type of the connection depends on the persistence engine (JDBC, JNDI, etc).
All method calls provide the object fields and the object identity. The engine must always use the identity passed in the method call and never the identity contained in the object itself.
The stamp is an arbitrary object that is returned on object creation and loading and passed when performing a dirty check. The stamp can be used to detect object dirtyness in a more efficient manner in database that support a stamping mechanism (e.g. Oracle RAWID, Sybase TIMESTAMP).
An implementation of this object must be re-entrant and thread safe. It must depend on the connection passed in each method call and never hold a reference to a connection.
TransactionContext
,
PersistenceQuery
Nested Class Summary | |
---|---|
static interface |
Persistence.ColumnInfo
|
static interface |
Persistence.FieldInfo
|
Method Summary | |
---|---|
java.lang.Object |
create(Database database,
java.lang.Object conn,
java.lang.Object[] fields,
java.lang.Object identity)
Creates a new object in persistence storage. |
PersistenceQuery |
createQuery(QueryExpression query,
java.lang.Class[] types,
AccessMode accessMode)
Creates and returns a new query object. |
void |
delete(java.lang.Object conn,
java.lang.Object identity)
Deletes the object from persistent storage, given the object' identity. |
Persistence.ColumnInfo[] |
getColumnInfoForIdentities()
Returns ColumnInfos for identifiers. |
Persistence.FieldInfo[] |
getInfo()
Returns FieldInfos for fields (excluding identifiers). |
java.lang.Object |
load(java.lang.Object conn,
ProposedObject proposedObject,
java.lang.Object identity,
AccessMode accessMode)
Loads the object from persistence storage. |
java.lang.Object |
store(java.lang.Object conn,
java.lang.Object[] fields,
java.lang.Object identity,
java.lang.Object[] original,
java.lang.Object stamp)
Stores the object in persistent storage, given the object fields and its identity. |
void |
writeLock(java.lang.Object conn,
java.lang.Object identity)
Obtains a write lock on the object. |
Method Detail |
---|
java.lang.Object create(Database database, java.lang.Object conn, java.lang.Object[] fields, java.lang.Object identity) throws DuplicateIdentityException, PersistenceException
conn
- An open connectionfields
- The fields to storeidentity
- The object's identity
DuplicateIdentityException
- An object with the same
identity already exists in persistent storage
PersistenceException
- A persistence error occuredjava.lang.Object load(java.lang.Object conn, ProposedObject proposedObject, java.lang.Object identity, AccessMode accessMode) throws ObjectNotFoundException, PersistenceException
store(java.lang.Object, java.lang.Object[], java.lang.Object, java.lang.Object[], java.lang.Object)
). If lock is true the object must be
locked in persistence storage to prevent concurrent updates.
conn
- An open connectionfields
- The fields to load intoidentity
- object's identityaccessMode
- The access mode (null equals shared)
ObjectNotFoundException
- The object was not found in
persistent storage
PersistenceException
- A persistence error occuredjava.lang.Object store(java.lang.Object conn, java.lang.Object[] fields, java.lang.Object identity, java.lang.Object[] original, java.lang.Object stamp) throws ObjectModifiedException, ObjectDeletedException, PersistenceException
create(org.exolab.castor.jdo.Database, java.lang.Object, java.lang.Object[], java.lang.Object)
. This method should
detect whether the object has been modified in persistent storage
since it was loaded. After this method returns all locks on the
object must be retained until the transaction has completed.
This method may return a new stamp to track further updates to
the object.
If the object was not retrieved for exclusive access, this
method will be asked to perform dirty checking prior to storing
the object. The original argument will contains the
object's original fields as retrieved in the transaction, and
stamp the object's stamp returned from a successful
call to load(java.lang.Object, org.castor.persist.ProposedObject, java.lang.Object, org.exolab.castor.mapping.AccessMode)
. These arguments are null for objects
retrieved with an exclusive lock.
conn
- An open connectionfields
- The fields to storeidentity
- The object's identityoriginal
- The original fields, or nullstamp
- The object's stamp, or null
ObjectModifiedException
- The object has been modified
in persistence storage since it was last loaded
ObjectDeletedException
- Indicates the object has been
deleted from persistence storage
PersistenceException
- A persistence error occuredvoid delete(java.lang.Object conn, java.lang.Object identity) throws PersistenceException
create(org.exolab.castor.jdo.Database, java.lang.Object, java.lang.Object[], java.lang.Object)
. After this method returns all
locks on the object must be retained until the transaction has
completed.
conn
- An open connectionidentity
- The object's identity
PersistenceException
- A persistence error occuredvoid writeLock(java.lang.Object conn, java.lang.Object identity) throws ObjectDeletedException, PersistenceException
conn
- An open connectionidentity
- The object's identity
ObjectDeletedException
- Indicates the object has been
deleted from persistence storage
PersistenceException
- A persistence error occuredPersistenceQuery createQuery(QueryExpression query, java.lang.Class[] types, AccessMode accessMode) throws QueryException
query
- The query expressiontypes
- List of all parameter types, or null
QueryException
- The query is invalidPersistence.ColumnInfo[] getColumnInfoForIdentities()
Persistence.FieldInfo[] getInfo()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |