org.apache.ojb.odmg
Class NarrowTransaction

java.lang.Object
  extended by org.apache.ojb.odmg.NarrowTransaction
All Implemented Interfaces:
HasBroker, TransactionExt, Transaction

public class NarrowTransaction
extends java.lang.Object
implements TransactionExt

Wraps Transaction in managed environments.

Author:
Armin Waibel

Field Summary
 
Fields inherited from interface org.odmg.Transaction
READ, UPGRADE, WRITE
 
Constructor Summary
NarrowTransaction(TransactionImpl tx)
           
 
Method Summary
 void abort()
          Abort the underlying odmg-transaction
 void begin()
          Not supported!!
 void checkpoint()
          Not supported!!
 void commit()
          Not supported!!
 void flush()
           Calling flush flushes persistent object modifications made within the ODMG transaction since the last checkpoint to the underlying database transaction, but does commit the database transaction.
 PersistenceBroker getBroker()
          Return associated PB instance, or null if not found.
 java.lang.Object getObjectByIdentity(Identity id)
           
 TransactionImpl getRealTransaction()
           
 boolean isDeleted(Identity id)
          Checks if the object with the given Identity has been deleted within the transaction using Database.deletePersistent(Object) or TransactionExt.markDelete(Object).
 boolean isImplicitLocking()
          Returns true if implicite locking is enabled.
 boolean isOpen()
          Not supported!!
 boolean isOrdering()
          Return true if the OJB ordering algorithm is enabled.
 void join()
          Not supported!!
 void leave()
          Not supported!!
 void lock(java.lang.Object obj, int lockMode)
          lock the given object
 void markDelete(java.lang.Object anObject)
          Marks an object for deletion without locking the object.
 void markDirty(java.lang.Object anObject)
          Marks an object as dirty without locking the object.
 void setCascadingDelete(java.lang.Class target, boolean doCascade)
          Allows to change the cascading delete behavior of all references of the specified class while this transaction is in use.
 void setCascadingDelete(java.lang.Class target, java.lang.String referenceField, boolean doCascade)
          Allows to change the cascading delete behavior of the target class's reference field while this transaction is in use.
 void setImplicitLocking(boolean value)
          This method can be used to activate or deactivate the implicit locking mechanism for the current transaction.
 void setOrdering(boolean ordering)
          Allows to enable/disable the OJB persistent object ordering algorithm.
 boolean tryLock(java.lang.Object obj, int lockMode)
          lock the given object if possible
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NarrowTransaction

public NarrowTransaction(TransactionImpl tx)
Method Detail

getRealTransaction

public TransactionImpl getRealTransaction()

markDelete

public void markDelete(java.lang.Object anObject)
Description copied from interface: TransactionExt
Marks an object for deletion without locking the object. If the object wasn't locked before, OJB will ask for a WRITE lock at commit.

Specified by:
markDelete in interface TransactionExt
Parameters:
anObject - Object to be marked

markDirty

public void markDirty(java.lang.Object anObject)
Description copied from interface: TransactionExt
Marks an object as dirty without locking the object. If the object wasn't locked before, OJB will ask for a WRITE lock at commit.

Specified by:
markDirty in interface TransactionExt
Parameters:
anObject - Object to be marked

flush

public void flush()
Description copied from interface: TransactionExt

Calling flush flushes persistent object modifications made within the ODMG transaction since the last checkpoint to the underlying database transaction, but does commit the database transaction. The ODMG transaction retains all locks it held on those objects at the time the flush was invoked.

This method is very similair to Transaction.checkpoint().

Specified by:
flush in interface TransactionExt

getBroker

public PersistenceBroker getBroker()
Return associated PB instance, or null if not found.

Specified by:
getBroker in interface HasBroker

join

public void join()
Not supported!!

Specified by:
join in interface Transaction

leave

public void leave()
Not supported!!

Specified by:
leave in interface Transaction

begin

public void begin()
Not supported!!

Specified by:
begin in interface Transaction

isOpen

public boolean isOpen()
Not supported!!

Specified by:
isOpen in interface Transaction
Returns:
True if the transaction is open, otherwise false.

commit

public void commit()
Not supported!!

Specified by:
commit in interface Transaction

abort

public void abort()
Abort the underlying odmg-transaction

Specified by:
abort in interface Transaction

checkpoint

public void checkpoint()
Not supported!!

Specified by:
checkpoint in interface Transaction

lock

public void lock(java.lang.Object obj,
                 int lockMode)
          throws LockNotGrantedException
lock the given object

Specified by:
lock in interface Transaction
Parameters:
obj - The object to acquire a lock on.
lockMode - The lock mode to acquire. The lock modes are READ, UPGRADE, and WRITE.
Throws:
LockNotGrantedException - Is thrown if the given lock mode could not be acquired.
See Also:
Transaction.lock(java.lang.Object, int)

tryLock

public boolean tryLock(java.lang.Object obj,
                       int lockMode)
lock the given object if possible

Specified by:
tryLock in interface Transaction
Parameters:
obj - The object to acquire a lock on.
lockMode - The lock mode to acquire. The lock modes are READ, UPGRADE, and WRITE.
Returns:
True if the lock has been acquired, otherwise false.
See Also:
Transaction.tryLock(java.lang.Object, int)

getObjectByIdentity

public java.lang.Object getObjectByIdentity(Identity id)
                                     throws PersistenceBrokerException
Throws:
PersistenceBrokerException

setImplicitLocking

public void setImplicitLocking(boolean value)
Description copied from interface: TransactionExt
This method can be used to activate or deactivate the implicit locking mechanism for the current transaction.
If set true OJB implicitly locks objects to ODMG transactions after performing OQL queries. Also if implicit locking is used locking objects is recursive, that is associated objects are also locked. If ImplicitLocking is set to 'false', no locks are obtained in OQL queries, lookup objects and there is also no recursive locking.

Turning off implicit locking may improve performance but requires additional care to make sure all changed objects are properly registered to the transaction.

Specified by:
setImplicitLocking in interface TransactionExt
Parameters:
value - If set true implicit locking is enabled, if false, implicit locking is disabled.
See Also:
TransactionExt.setImplicitLocking(boolean)

isImplicitLocking

public boolean isImplicitLocking()
Description copied from interface: TransactionExt
Returns true if implicite locking is enabled.

Specified by:
isImplicitLocking in interface TransactionExt
See Also:
TransactionExt.isImplicitLocking()

setCascadingDelete

public void setCascadingDelete(java.lang.Class target,
                               java.lang.String referenceField,
                               boolean doCascade)
Description copied from interface: TransactionExt
Allows to change the cascading delete behavior of the target class's reference field while this transaction is in use.

Specified by:
setCascadingDelete in interface TransactionExt
Parameters:
target - The class to change cascading delete behavior of the references.
referenceField - The field name of the 1:1, 1:n or m:n reference.
doCascade - If true cascading delete is enabled, false disabled.
See Also:
TransactionExt.setCascadingDelete(Class, String, boolean)

setCascadingDelete

public void setCascadingDelete(java.lang.Class target,
                               boolean doCascade)
Description copied from interface: TransactionExt
Allows to change the cascading delete behavior of all references of the specified class while this transaction is in use.

Specified by:
setCascadingDelete in interface TransactionExt
Parameters:
target - The class to change cascading delete behavior of all references.
doCascade - If true cascading delete is enabled, false disabled.
See Also:
TransactionExt.setCascadingDelete(Class, boolean)

isOrdering

public boolean isOrdering()
Description copied from interface: TransactionExt
Return true if the OJB ordering algorithm is enabled.

Specified by:
isOrdering in interface TransactionExt
See Also:
TransactionExt.setOrdering(boolean)

setOrdering

public void setOrdering(boolean ordering)
Description copied from interface: TransactionExt
Allows to enable/disable the OJB persistent object ordering algorithm. If true OJB try to order the modified/new/deleted objects in a correct order (based on a algorithm) before the objects are written to the persistent storage.
If the used databases support 'deferred checks' it's recommended to use this feature and to disable OJB's object ordering.

If false the order of the objects rely on the order specified by the user and on settings like TransactionExt.setImplicitLocking(boolean).

Specified by:
setOrdering in interface TransactionExt
Parameters:
ordering - Set true to enable object ordering on commit.
See Also:
ImplementationExt.setOrdering(boolean)

isDeleted

public boolean isDeleted(Identity id)
Description copied from interface: TransactionExt
Checks if the object with the given Identity has been deleted within the transaction using Database.deletePersistent(Object) or TransactionExt.markDelete(Object).

Specified by:
isDeleted in interface TransactionExt
Parameters:
id - The identity of the object.
Returns:
true if the object has been deleted within the transaction.


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30