- Version:
- $Id: BaseConnection.java,v 1.30 2004/02/23 19:10:21 brj Exp $
- Author:
- Matthew Baird , Raghu Rajah
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BaseConnection
public BaseConnection(PBKey pbKey)
- Constructor for BaseConnection.
close
public void close()
- Description copied from interface:
OTMConnection
- Close the OTMConnection
- Specified by:
close
in interface OTMConnection
isClosed
public boolean isClosed()
- Description copied from interface:
OTMConnection
- check if the OTMConnection is closed
- Specified by:
isClosed
in interface OTMConnection
getKernelBroker
public PersistenceBroker getKernelBroker()
setTransaction
public void setTransaction(Transaction transaction)
- Specified by:
setTransaction
in interface OTMConnection
getTransaction
public Transaction getTransaction()
- Specified by:
getTransaction
in interface OTMConnection
getObjectByIdentity
public java.lang.Object getObjectByIdentity(Identity oid,
int lock)
throws LockingException
- Description copied from interface:
OTMConnection
- Get the object with the given Identity from the persistent store with the given lock value.
- Specified by:
getObjectByIdentity
in interface OTMConnection
- Parameters:
oid
- the Identity of the object to fetchlock
- the lock that need to be acquired on the object
Possible values are:
LockType.NO_LOCK (aka read only) - changes to the object will not be written to database;
LockType.READ_LOCK (aka optimistic lock) - changes to the object will be written to the database,
in this case the lock will be automatically upgraded to the write lock on transaction commit;
LockType.WRITE_LOCK (aka pessimistic lock) - changes to the object will be written to the database.
- Returns:
- the object from the persistent store.
- Throws:
LockingException
- thrown by the LockManager to avoid a deadlock.- See Also:
OTMConnection.getObjectByIdentity(Identity, int)
getObjectByIdentity
public java.lang.Object getObjectByIdentity(Identity oid)
throws LockingException
- Description copied from interface:
OTMConnection
- Get the object with the given Identity from the persistent store. By default, the fetch is
for read. (OTM will automatically lock it for write on transaction commit
if the object will appear to be modified).
- Specified by:
getObjectByIdentity
in interface OTMConnection
- Parameters:
oid
- the Identity of the object to fetch
- Returns:
- the object from the persistent store.
- Throws:
LockingException
- thrown by the LockManager to avoid deadlocks. The fetch could be
re-submitted.- See Also:
OTMConnection.getObjectByIdentity(Identity)
getIteratorByQuery
public java.util.Iterator getIteratorByQuery(Query query)
- Specified by:
getIteratorByQuery
in interface OTMConnection
- Parameters:
query
- The query to execute
- Returns:
- an Iterator that iterates Objects. The returned objects are locked for read.
getIteratorByQuery
public java.util.Iterator getIteratorByQuery(Query query,
int lock)
- Specified by:
getIteratorByQuery
in interface OTMConnection
- Parameters:
query
- The query to executelock
- the lock that need to be acquired on the object Possible values are:
LockType.NO_LOCK (aka read only) - changes to the object will not be written to
database; LockType.READ_LOCK (aka optimistic lock) - changes to the object will
be written to the database, in this case the lock will be automatically upgraded
to the write lock on transaction commit; LockType.WRITE_LOCK (aka pessimistic
lock) - changes to the object will be written to the database.
- Returns:
- an Iterator that iterates Objects of class c if calling the .next() method. The
returned objects are locked with the given lock value.
getIteratorByOQLQuery
public java.util.Iterator getIteratorByOQLQuery(OQLQuery query)
- Specified by:
getIteratorByOQLQuery
in interface OTMConnection
- Parameters:
query
- The OQL query to execute. Use this method if you don't want to load all the
collection at once as OQLQuery.execute() does.
- Returns:
- an Iterator that iterates Objects. The returned objects are locked for read.
getIteratorByOQLQuery
public java.util.Iterator getIteratorByOQLQuery(OQLQuery query,
int lock)
- Specified by:
getIteratorByOQLQuery
in interface OTMConnection
- Parameters:
query
- The OQL query to execute. Use this method if you don't want to load all the
collection at once as OQLQuery.execute() does.lock
- the lock that need to be acquired on the object
Possible values are:
LockType.NO_LOCK (aka read only) - changes to the object will not be written to database;
LockType.READ_LOCK (aka optimistic lock) - changes to the object will be written to the database,
in this case the lock will be automatically upgraded to the write lock on transaction commit;
LockType.WRITE_LOCK (aka pessimistic lock) - changes to the object will be written to the database.
- Returns:
- an Iterator that iterates Objects. The returned objects are locked for read.
getCollectionByQuery
public java.util.Collection getCollectionByQuery(Query query,
int lock)
- Specified by:
getCollectionByQuery
in interface OTMConnection
- Parameters:
query
- The query to executelock
- the lock that need to be acquired on the object Possible values are:
LockType.NO_LOCK (aka read only) - changes to the object will not be written to
database; LockType.READ_LOCK (aka optimistic lock) - changes to the object will
be written to the database, in this case the lock will be automatically upgraded
to the write lock on transaction commit; LockType.WRITE_LOCK (aka pessimistic
lock) - changes to the object will be written to the database.
- Returns:
- an Iterator that iterates Objects of class c if calling the .next() method. The
returned objects are locked with the given lock value.
getCollectionByQuery
public java.util.Collection getCollectionByQuery(Query query)
- Specified by:
getCollectionByQuery
in interface OTMConnection
- Parameters:
query
- The query to execute
- Returns:
- an Iterator that iterates Objects of class c if calling the .next() method. The
returned objects are locked for read.
getIdentity
public Identity getIdentity(java.lang.Object object)
- Get the identity of the object
- Specified by:
getIdentity
in interface OTMConnection
- Parameters:
object
- The object
- Returns:
- the identity of the object
getDescriptorFor
public ClassDescriptor getDescriptorFor(java.lang.Class clazz)
- Get the class descriptor
- Specified by:
getDescriptorFor
in interface OTMConnection
- Parameters:
clazz
- The class
- Returns:
- the descriptor of the class
invalidate
public void invalidate(Identity oid)
throws LockingException
- Description copied from interface:
OTMConnection
- In the case if the program need to change the objects
via direct JDBC call, it should first call invalidate()
for the object, which will lock the object for write
and tell OJB OTM that it must be re-read from the database,
only after that you shold perform JDBC operation.
NOTE: it is not recommended to use read-uncommitted isolation
if you want this feature to work correctly.
- Specified by:
invalidate
in interface OTMConnection
- Throws:
LockingException
- See Also:
OTMConnection.invalidate(Identity)
serviceObjectCache
public ObjectCache serviceObjectCache()
- Description copied from interface:
OTMConnection
- get the global cache
- Specified by:
serviceObjectCache
in interface OTMConnection
- Returns:
- See Also:
OTMConnection.serviceObjectCache()
invalidateAll
public void invalidateAll()
throws LockingException
- TODO remove all from editing context.
- Specified by:
invalidateAll
in interface OTMConnection
- Throws:
LockingException
lockForWrite
public void lockForWrite(java.lang.Object object)
throws LockingException
- Description copied from interface:
OTMConnection
- Lock the given object for Write. Only write locked objects are persisted back to the
database. Changes to read objects are not inserted back into the database.
- Specified by:
lockForWrite
in interface OTMConnection
- Parameters:
object
- the object to be locked for write.
- Throws:
LockingException
- See Also:
OTMConnection.lockForWrite(Object)
makePersistent
public void makePersistent(java.lang.Object object)
throws LockingException
- Description copied from interface:
OTMConnection
- Make the given object persistent by inserting it into the database.
Also read locks the object (OTM will automatically lock
it for write on transaction commit if the object will appear
to be modified).
- Specified by:
makePersistent
in interface OTMConnection
- Parameters:
object
- the object to be made persistent
- Throws:
LockingException
- See Also:
OTMConnection.makePersistent(Object)
deletePersistent
public void deletePersistent(java.lang.Object object)
throws LockingException
- Description copied from interface:
OTMConnection
- Mark the given object for deletion from the persistent store. The object would then become
a transient object, rather than a persistent one.
- Specified by:
deletePersistent
in interface OTMConnection
- Parameters:
object
- the object to delete
- Throws:
LockingException
- See Also:
OTMConnection.deletePersistent(Object)
getEditingContext
public EditingContext getEditingContext()
- Description copied from interface:
OTMConnection
- Get the EditingContext associated with the transaction to which this connection belongs.
EditingContext contains and manages the set of objects read/edited within the current
transaction.
- Specified by:
getEditingContext
in interface OTMConnection
- Returns:
- EditingContext associated with current Transaction
newOQLQuery
public EnhancedOQLQuery newOQLQuery()
- Description copied from interface:
OTMConnection
- returns a new OQL Query. This OQL query is Enhanced, meaning it does
the ODMG functionality as well as some additional OJB specific, non
portable functionality.
- Specified by:
newOQLQuery
in interface OTMConnection
- Returns:
- the new OQLQuery
newOQLQuery
public EnhancedOQLQuery newOQLQuery(int lock)
- Description copied from interface:
OTMConnection
- returns a new OQL Query. This OQL query is Enhanced, meaning it does
the ODMG functionality as well as some additional OJB specific, non
portable functionality.
- Specified by:
newOQLQuery
in interface OTMConnection
- Parameters:
lock
- the lock that need to be acquired on the object
Possible values are:
LockType.NO_LOCK (aka read only) - changes to the object will not be written to database;
LockType.READ_LOCK (aka optimistic lock) - changes to the object will be written to the database,
in this case the lock will be automatically upgraded to the write lock on transaction commit;
LockType.WRITE_LOCK (aka pessimistic lock) - changes to the object will be written to the database.
- Returns:
- the new OQLQuery
getCount
public int getCount(Query query)
- Description copied from interface:
OTMConnection
- return the number of objects that would be returned from this query
- Specified by:
getCount
in interface OTMConnection
- Parameters:
query
-
- Returns:
- the number of objects that would be returned from this query
transactionBegin
public abstract void transactionBegin()
throws TransactionException
- Notification issued by the driving transaction to begin this transaction
- Throws:
TransactionException
transactionPrepare
public abstract void transactionPrepare()
throws TransactionException
- Prepare for a commit. As part of a two phase commit protocol of the transaction.
- Throws:
TransactionException
transactionCommit
public abstract void transactionCommit()
throws TransactionException
- Notification issued by the driving transaction to commit resources held by this connection.
- Throws:
TransactionException
transactionRollback
public abstract void transactionRollback()
throws TransactionException
- Notification issued by the driving transaction to rollback resources held by this
connection.
- Throws:
TransactionException
Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14