db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r422235 [3/3] - in /db/ojb/trunk/src: java/org/apache/ojb/odmg/ java/org/apache/ojb/odmg/oql/ java/org/apache/ojb/odmg/states/ java/org/odmg/ jdori/org/apache/ojb/jdori/sql/ samples/org/apache/ojb/tutorials/
Date Sat, 15 Jul 2006 14:28:05 GMT
Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/TransactionImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/TransactionImpl.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/TransactionImpl.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/TransactionImpl.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2006 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,12 +23,15 @@
 import java.util.List;
 
 import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.PBFactoryException;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.PersistenceBrokerInternal;
+import org.apache.ojb.broker.cache.SessionCache;
 import org.apache.ojb.broker.core.proxy.CollectionProxy;
 import org.apache.ojb.broker.core.proxy.CollectionProxyListener;
 import org.apache.ojb.broker.core.proxy.IndirectionHandler;
@@ -38,10 +41,12 @@
 import org.apache.ojb.broker.metadata.CollectionDescriptor;
 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
 import org.apache.ojb.broker.util.BrokerHelper;
-import org.apache.ojb.broker.util.GUID;
+import org.apache.ojb.broker.util.GUIDFactory;
+import org.apache.ojb.broker.util.IdentityArrayList;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 import org.apache.ojb.odmg.locking.LockManager;
+import org.apache.ojb.odmg.locking.LockManagerOdmgImpl;
 import org.odmg.DatabaseClosedException;
 import org.odmg.LockNotGrantedException;
 import org.odmg.ODMGRuntimeException;
@@ -50,13 +55,8 @@
 import org.odmg.TransactionNotInProgressException;
 
 /**
+ * Implementation of Transaction for {@link org.odmg.Transaction}.
  *
- * Implementation of Transaction for org.odmg.Transaction.
- *
- * @author     Thomas Mahler & David Dixon-Peugh
- * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
- * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
  * @version $Id$
  *
  */
@@ -64,16 +64,18 @@
         implements Transaction, MaterializationListener, CollectionProxyListener, TransactionExt
 {
     private Logger log = LoggerFactory.getLogger(TransactionImpl.class);
+
+    private static final GUIDFactory guid = new GUIDFactory();
+
+    private final String txGUID;
+    private final ImplementationImpl implementation;
+    private final NamedRootsMap namedRootsMap;
+    protected PersistenceBrokerInternal broker = null;
+    //private ArrayList registrationList = new ArrayList();
+
     private boolean impliciteWriteLocks;
     private boolean implicitLocking;
     private boolean ordering;
-    private boolean noteUserOrdering;
-
-    private String txGUID;
-    protected PersistenceBrokerInternal broker = null;
-    private ArrayList registrationList = new ArrayList();
-    private ImplementationImpl implementation;
-    private NamedRootsMap namedRootsMap;
 
     /**
      * The status of the current transaction, as specified by the
@@ -86,7 +88,7 @@
      * the internal table containing all Objects "touched" by this tx and their
      * respective transactional state
      */
-    protected ObjectEnvelopeTable objectEnvelopeTable = null;
+    public final ObjectEnvelopeTable objectEnvelopeTable;
 
     /**
      * reference to the currently opened database
@@ -99,17 +101,27 @@
      */
     private ArrayList registeredIndirectionHandlers = new ArrayList();
 
+    /*
+    arminw:
+    in both cases below we have to use identity based lists, because normal
+    lists will call obj.equals(...) which will materialize the proxy object
+    */
     /**
      * Unloaded collection proxies which will be registered with tx when
      * collection is loaded
      */
-    private ArrayList registeredCollectionProxies = new ArrayList();
+    private IdentityArrayList registeredCollectionProxies = new IdentityArrayList();
 
     /**
      * list of proxy objects that were locked, but haven't been materialized yet.
      * This is necessary so the locks can be released on closing the transaction
      */
-    private ArrayList unmaterializedLocks = new ArrayList();
+    private IdentityArrayList unmaterializedLocks = new IdentityArrayList();
+
+    /**
+     * This list is used to avoid endless loops on circular referenced objects.
+     */
+    private ArrayList currentRegistered = new ArrayList();
 
     /**
      * Creates new Transaction
@@ -121,12 +133,12 @@
         this.impliciteWriteLocks = implementation.isImpliciteWriteLocks();
         this.implicitLocking = implementation.isImplicitLocking();
         this.ordering = implementation.isOrdering();
-        this.noteUserOrdering = implementation.isNoteUserOrder();
-
-        // assign a globally uniqe id to this tx
-        txGUID = new GUID().toString();
+        // assign a uniqe id to this tx
+        txGUID = guid.next();
         curDB = implementation.getCurrentDatabase();
         namedRootsMap = new NamedRootsMap(this);
+        // initialize the ObjectEnvelope table
+        objectEnvelopeTable = new ObjectEnvelopeTable(this);
     }
 
     public ImplementationImpl getImplementation()
@@ -221,70 +233,112 @@
         if (log.isDebugEnabled()) log.debug("lock object was called on tx " + this + ", object is " + obj.toString());
         checkOpen();
         RuntimeObject rtObject = new RuntimeObject(obj, this);
-        lockAndRegister(rtObject, lockMode, isImplicitLocking(), getRegistrationList());
-        if(isImplicitLocking()) moveToLastInOrderList(rtObject.getIdentity());
+        lockAndRegister(rtObject, lockMode, isImplicitLocking());
     }
 
     /**
-     * Returns an empty List for registration of processed object Identity.
-     */
-    public ArrayList getRegistrationList()
-    {
-        clearRegistrationList();
-        return registrationList;
-    }
-
-    /**
-     * Clears the list of processed object Identity.
+     * Lock and register the specified object, make sure that when cascading locking and register
+     * is enabled to specify a List to register the already processed object Identiy.
      */
-    public void clearRegistrationList()
+    public void lockAndRegister(RuntimeObject rtObject, int lockMode)
     {
-        registrationList.clear();
+        lockAndRegister(rtObject, lockMode, isImplicitLocking());
     }
 
     /**
      * Lock and register the specified object, make sure that when cascading locking and register
      * is enabled to specify a List to register the already processed object Identiy.
      */
-    public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
+    public synchronized void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade)
     {
-        lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
+        internalLockRegister(rtObject, lockMode, cascade);
+        if(currentRegistered.size() > 0) currentRegistered.clear();
     }
 
     /**
      * Lock and register the specified object, make sure that when cascading locking and register
      * is enabled to specify a List to register the already processed object Identiy.
      */
-    public void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade, List registeredObjects)
+    private void internalLockRegister(final RuntimeObject rtObject, final int lockMode, final boolean cascade)
     {
+        if(log.isDebugEnabled()) log.debug("Lock and register called for " + rtObject.getIdentity());
         // if current object was already locked, do nothing
         // avoid endless loops when circular object references are used
-        if(!registeredObjects.contains(rtObject.getIdentity()))
+        Identity oid = rtObject.getIdentity();
+        ObjectEnvelope mod = objectEnvelopeTable.getByIdentity(oid);
+        if(mod == null && !currentRegistered.contains(oid))
         {
+            currentRegistered.add(oid);
+            Object objectToRegister = rtObject.getObj();
             /*
             arminw: This is used to re-/initialize OJBAssociate objects
             (e.g. the odmg collection implementations use this interface)
             with current pc-configuration and OJB's tx-manager.
             */
             getImplementation().prepareOJBBaseInstance(rtObject.getObj());
-            if(cascade) registeredObjects.add(rtObject.getIdentity());
+            /*
+            if the object is a Proxy there are two options:
+            1. The proxies real subject has already been materialized:
+               we take this real subject as the object to register and proceed
+               as if it were a ordinary object.
+            2. The real subject has not been materialized: Then there is nothing
+               to be registered now!
+               Of course we might just materialize the real subject to have something
+               to register. But this would make proxies useless for ODMG as proxies would
+               get materialized even if their real subjects were not used by the
+               client app.
+               Thus we register the current transaction as a Listener to the IndirectionHandler
+               of the Proxy.
+               Only when the IndirectionHandler performs the materialization of the real subject
+               at some later point in time it invokes callbacks on all it's listeners.
+               Using this callback we can defer the registering until it's really needed.
+            */
+            if(rtObject.isProxy())
+            {
+                IndirectionHandler handler = rtObject.getHandler();
+                if(handler == null)
+                {
+                    throw new OJBRuntimeException("Unexpected error, expect an proxy object as indicated: " + rtObject);
+                }
+                if (handler.alreadyMaterialized())
+                {
+                    objectToRegister = handler.getRealSubject();
+                }
+                else
+                {
+                    lockUnmaterializedObject(rtObject, lockMode, handler);
+                    // all work is done, so set to null to skip
+                    // "normal" registration/lock below
+                    objectToRegister = null;
+                }
+            }
+            if(objectToRegister != null)
+            {
+                if(cascade)
+                {
+                    // lock and register 1:1 references first
+                    //
+                    // If implicit locking is used, we have to use the materialized main object
+                    // to lock the referenced objects too
+                    internalLockRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(), lockMode, cascade);
+                }
             try
             {
                 // perform the lock on the object
                 // we don't need to lock new objects
                 if(!rtObject.isNew())
                 {
-                    doSingleLock(rtObject.getCld(), rtObject.getObj(), rtObject.getIdentity(), lockMode);
+                        internalSingleLock(rtObject.getCld(), rtObject.getIdentity(), lockMode);
                 }
-                // now register specified object + register and lock recursive all referenced objects
                 // after we locked the object, register it to detect status and changes while tx
-                register(rtObject, lockMode, cascade, registeredObjects);
+                    internalSingleRegister(rtObject, lockMode);
             }
             catch (Throwable t)
             {
                 //log.error("Locking of obj " + rtObject.getIdentity() + " failed", t);
-                // if registering of object fails, release lock on object
-                implementation.getLockManager().releaseLock(this, rtObject.getIdentity(), rtObject.getObj());
+                // if registering of object fails release lock on object, because later we don't
+                // get a change to do this.
+                    implementation.getLockManager().releaseLock(this, rtObject.getIdentity());
                 if(t instanceof LockNotGrantedException)
                 {
                     throw (LockNotGrantedException) t;
@@ -297,6 +351,31 @@
                             + ": " + t.getMessage() + "]");
                 }
             }
+                if(cascade)
+                {
+                    // perform locks and register 1:n and m:n references
+                    // If implicit locking is used, we have to use the materialized main object
+                    // to lock the referenced objects too
+                    internalLockRegisterCollections(rtObject.getCld(), rtObject.getObjMaterialized(), lockMode, cascade);
+        }
+    }
+        }
+        else
+        {
+            /*
+            TODO:
+            Replace this intransparent detach/attach workaround with a
+            real detach/attach service
+            */
+            if(mod != null)
+            {
+                // only use real objects, no proxy instances
+                Object realObj = rtObject.getObjMaterialized();
+                if(realObj != null)
+                {
+                    mod.refreshObjectIfNeeded(realObj);
+                }
+            }
         }
     }
 
@@ -312,15 +391,15 @@
      *
      * @exception  LockNotGrantedException    Description of Exception
      */
-    void doSingleLock(ClassDescriptor cld, Object obj, Identity oid, int lockMode) throws LockNotGrantedException
+    void internalSingleLock(final ClassDescriptor cld, final Identity oid, final int lockMode) throws LockNotGrantedException
     {
-        LockManager lm = implementation.getLockManager();
         if (cld.isAcceptLocks())
         {
+            LockManager lm = implementation.getLockManager();
             if (lockMode == Transaction.READ)
             {
                 if (log.isDebugEnabled()) log.debug("Do READ lock on object: " + oid);
-                if(!lm.readLock(this, oid, obj))
+                if(!lm.readLock(this, oid, cld))
                 {
                     throw new LockNotGrantedException("Can not lock for READ: " + oid);
                 }
@@ -328,7 +407,7 @@
             else if (lockMode == Transaction.WRITE)
             {
                 if (log.isDebugEnabled()) log.debug("Do WRITE lock on object: " + oid);
-                if(!lm.writeLock(this, oid, obj))
+                if(!lm.writeLock(this, oid, cld))
                 {
                     throw new LockNotGrantedException("Can not lock for WRITE: " + oid);
                 }
@@ -336,7 +415,7 @@
             else if (lockMode == Transaction.UPGRADE)
             {
                 if (log.isDebugEnabled()) log.debug("Do UPGRADE lock on object: " + oid);
-                if(!lm.upgradeLock(this, oid, obj))
+                if(!lm.upgradeLock(this, oid, cld))
                 {
                     throw new LockNotGrantedException("Can not lock for UPGRADE: " + oid);
                 }
@@ -344,9 +423,11 @@
         }
         else
         {
-            if (log.isDebugEnabled()) log.debug("Class '" + cld.getClassNameOfObject()
-                    + "' doesn't accept locks (specified in class-descriptor), so OJB skip this object: "
-                    + oid);
+            if (log.isDebugEnabled())
+            {
+                log.debug("Class '" + cld.getClassNameOfObject() + "' doesn't accept locks" +
+                        " (accept-locks=false) when implicite locked, so OJB skip this object: " + oid);
+            }
         }
     }
 
@@ -374,6 +455,7 @@
         if (!getBroker().isInTransaction())
         {
             if (log.isDebugEnabled()) log.debug("call beginTransaction() on PB instance");
+            broker.setManaged(implementation.isManaged());
             broker.beginTransaction();
         }
 
@@ -385,7 +467,7 @@
         // now we have to perform the named objects
         namedRootsMap.performDeletion();
         namedRootsMap.performInsert();
-        namedRootsMap.afterWriteCleanup();
+        namedRootsMap.cleanup();
     }
 
     /**
@@ -399,6 +481,7 @@
         performTransactionAwareBeforeRollback();
 
         // Now, we abort everything. . .
+        namedRootsMap.cleanup();
         objectEnvelopeTable.rollback();
 
         // Now, we notify everything the abort is done.
@@ -412,23 +495,21 @@
     {
         try
         {
-            LockManager lm = getImplementation().getLockManager();
-            Enumeration en = objectEnvelopeTable.elements();
-            while (en.hasMoreElements())
+            try
             {
-                ObjectEnvelope oe = (ObjectEnvelope) en.nextElement();
-                lm.releaseLock(this, oe.getIdentity(), oe.getObject());
+                // this tx is no longer interested in materialization callbacks
+                unRegisterFromAllIndirectionHandlers();
+                unRegisterFromAllCollectionProxies();
             }
-
-            //remove locks for objects which haven't been materialized yet
-            for (Iterator it = unmaterializedLocks.iterator(); it.hasNext();)
+            catch(Exception e)
             {
-                lm.releaseLock(this, it.next());
+                log.error("Unexpected error while unregister transaction from proxy listener", e);
             }
 
-            // this tx is no longer interested in materialization callbacks
-            unRegisterFromAllIndirectionHandlers();
-            unRegisterFromAllCollectionProxies();
+            LockManager lm = getImplementation().getLockManager();
+            // this call is important to unlock registered
+            // objects and unregistered proxies
+            lm.releaseLocks(this);
         }
         finally
         {
@@ -437,41 +518,28 @@
              */
             if (log.isDebugEnabled())
                 log.debug("Close Transaction and release current PB " + broker + " on tx " + this);
+            txStatus = Status.STATUS_NO_TRANSACTION;
             // remove current thread from LocalTxManager
             // to avoid problems for succeeding calls of the same thread
             implementation.getTxManager().deregisterTx(this);
-            // now cleanup and prepare for reuse
-            refresh();
+            // now cleanup the use broker instance
+            cleanupBroker();
         }
     }
 
     /**
-     * cleanup tx and prepare for reuse
+     * Prepare this tx for reuse
      */
     protected void refresh()
     {
-        if (log.isDebugEnabled())
-                log.debug("Refresh this transaction for reuse: " + this);
-        try
-        {
+        if (log.isDebugEnabled()) log.debug("Refresh this transaction for reuse: " + this);
             // we reuse ObjectEnvelopeTable instance
-            objectEnvelopeTable.refresh();
-        }
-        catch (Exception e)
-        {
-            if (log.isDebugEnabled())
-            {
-                log.debug("error closing object envelope table : " + e.getMessage());
-                e.printStackTrace();
-            }
-        }
-        cleanupBroker();
+        objectEnvelopeTable.prepareForUse();
         // clear the temporary used named roots map
         // we should do that, because same tx instance
         // could be used several times
         broker = null;
-        clearRegistrationList();
-        unmaterializedLocks.clear();
+        if(unmaterializedLocks.size() > 0) unmaterializedLocks.clear();
         txStatus = Status.STATUS_NO_TRANSACTION;
     }
 
@@ -525,7 +593,7 @@
         }
         catch (Throwable t)
         {
-            log.error("flush failed", t);
+            log.error("Calling method 'tx.flush()' failed", t);
             txStatus = Status.STATUS_MARKED_ROLLBACK;
             abort();
             if(!(t instanceof ODMGRuntimeException))
@@ -561,7 +629,7 @@
             Object realObj = rt.getHandler().getRealSubject();
             rt = new RuntimeObject(realObj, rt.getIdentity(), this, false);
         }
-        lockAndRegister(rt, Transaction.WRITE, getRegistrationList());
+        lockAndRegister(rt, Transaction.WRITE);
         ObjectEnvelope oe = objectEnvelopeTable.getByIdentity(rt.getIdentity());
         // TODO: not needed on delete - or? When optimistic locking is used we should always use the
         // specified object instance to use the last version of the object
@@ -608,7 +676,7 @@
     {
         try
         {
-            lockAndRegister(rt, Transaction.WRITE, getRegistrationList());
+            lockAndRegister(rt, Transaction.WRITE);
             markPersistent(rt);
         }
         catch (org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException ex)
@@ -652,6 +720,11 @@
         }
     }
 
+    private boolean needFullCommit()
+    {
+        return objectEnvelopeTable.registeredObjectCount() > 0 || namedRootsMap.needsCommit();
+    }
+
     /**
      * Commit and close the transaction. Calling <code>commit</code> commits to
      * the database all persistent object modifications within the transaction and
@@ -676,13 +749,16 @@
         checkOpen();
         try
         {
+            if(needFullCommit())
+            {
             prepareCommit();
             checkForCommit();
 
             txStatus = Status.STATUS_COMMITTING;
             if (log.isDebugEnabled()) log.debug("Commit transaction " + this);
+            }
             // now do real commit on broker
-            if(hasBroker()) getBroker().commitTransaction();
+            if(hasBroker() && getBroker().isInTransaction()) getBroker().commitTransaction();
 
             // Now, we notify everything the commit is done.
             performTransactionAwareAfterCommit();
@@ -807,6 +883,7 @@
         finally
         {
             txStatus = Status.STATUS_ROLLEDBACK;
+            // cleanup things, e.g. release all locks
             doClose();
         }
     }
@@ -825,15 +902,14 @@
     {
         checkForBegin();
         if (log.isDebugEnabled()) log.debug("Begin transaction was called on tx " + this);
-        // initialize the ObjectEnvelope table
-        objectEnvelopeTable = new ObjectEnvelopeTable(this);
+        refresh();
         // register transaction
         implementation.getTxManager().registerTx(this);
         // mark tx as active (open)
         txStatus = Status.STATUS_ACTIVE;
     }
 
-    protected void checkForBegin()
+    private void checkForBegin()
     {
         /**
          * Is the associated database non-null and open? ODMG 3.0 says it must be.
@@ -849,6 +925,10 @@
         }
     }
 
+    /**
+     * Returns a global unique identifier for this transaction generated
+     * by {@link org.apache.ojb.broker.util.GUIDFactory}.
+     */
     public String getGUID()
     {
         return txGUID;
@@ -877,99 +957,42 @@
     }
 
     /**
-     * Registers the object (without locking) with this transaction and if cascade is <em>true</em>
-     * recursively all associations (a implicite lock is acquired for associations). This method
-     * expect that the main object is already locked!!!
+     * Registers the object (without locking) with this transaction. This method
+     * expects that the object was already locked, no check is done!!!
      */
-    private synchronized void register(RuntimeObject rtObject, int lockMode, boolean cascade, List registeredObjects)
+    private void internalSingleRegister(RuntimeObject rtObject, int lockMode)
             throws LockNotGrantedException, PersistenceBrokerException
     {
-        Object objectToRegister = rtObject.getObj();
-        /*
-        if the object is a Proxy there are two options:
-        1. The proxies real subject has already been materialized:
-           we take this real subject as the object to register and proceed
-           as if it were a ordinary object.
-        2. The real subject has not been materialized: Then there is nothing
-           to be registered now!
-           Of course we might just materialize the real subject to have something
-           to register. But this would make proxies useless for ODMG as proxies would
-           get materialized even if their real subjects were not used by the
-           client app.
-           Thus we register the current transaction as a Listener to the IndirectionHandler
-           of the Proxy.
-           Only when the IndirectionHandler performs the materialization of the real subject
-           at some later point in time it invokes callbacks on all it's listeners.
-           Using this callback we can defer the registering until it's really needed.
-        */
-        if(rtObject.isProxy())
+        if(log.isDebugEnabled()) log.debug("Register object " + rtObject.getIdentity());
+        // no Proxy and is not null, register real object
+        ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(rtObject.getIdentity());
+        // if we found an envelope, object is already registered --> we do nothing
+        // than refreshing the object!
+        if ((envelope == null))
         {
-            IndirectionHandler handler = rtObject.getHandler();
-            if(handler == null)
-            {
-                throw new OJBRuntimeException("Unexpected error, expect an proxy object as indicated: " + rtObject);
-            }
-            if (handler.alreadyMaterialized())
-            {
-                objectToRegister = handler.getRealSubject();
-            }
-            else
-            {
-                registerToIndirectionHandler(handler);
-                registerUnmaterializedLocks(rtObject.getObj());
-                // all work is done, so set to null
-                objectToRegister = null;
-            }
+            // register object itself
+            envelope = objectEnvelopeTable.get(rtObject.getIdentity(), rtObject.getObj(), rtObject.isNew());
         }
-        // no Proxy and is not null, register real object
-        if (objectToRegister != null)
+        else
         {
-            // register associated 1:1 objects
-            if(cascade)
-            {
-                // it's save to call RTO#getObjMaterialized because we know that
-                // the object is a non-null normal object or an materialized proxy
-                // and the method returns in any case the real object
-                lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(), getImpliciteLockType(lockMode), registeredObjects);
-            }
-
-            ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(rtObject.getIdentity());
-            // if we found an envelope, object is already registered --> we do nothing
-            // than refreshing the object!
-            if ((envelope == null))
-            {
-                // register object itself
-                envelope = objectEnvelopeTable.get(rtObject.getIdentity(), objectToRegister, rtObject.isNew());
-            }
-            else
-            {
-                /*
-                arminw:
-                if an different instance of the same object was locked again
-                we should replace the old instance with new one to make
-                accessible the changed fields
-                */
-                envelope.refreshObjectIfNeeded(objectToRegister);
-            }
             /*
+            TODO: replace this intransparent handling with detach/attach service
             arminw:
-            For better performance we check if this object has already a write lock
-            in this case we don't need to acquire a write lock on commit
+            if an different instance of the same object was locked again
+            we should replace the old instance with new one to make
+            accessible the changed fields
             */
-            if(lockMode == Transaction.WRITE)
-            {
-                // signal ObjectEnvelope that a WRITE lock is already acquired
-                envelope.setWriteLocked(true);
-            }
-            // register associated 1:n and m:n objects
-            if(cascade)
-            {
-                // it's save to call RTO#getObjMaterialized because we know that
-                // the object is a non-null normal object or an materialized proxy
-                // and the method returns in any case the real object
-                //lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(), getImpliciteLockType(lockMode), registeredObjects);
-                lockAndRegisterCollections(rtObject.getCld(), rtObject.getObjMaterialized(), getImpliciteLockType(lockMode), registeredObjects);
-            }
+            envelope.refreshObjectIfNeeded(rtObject.getObj());
+        }
+        /*
+        arminw:
+        For better performance we check if this object has already a write lock
+        in this case we don't need to acquire a write lock on commit
+        */
+        if(lockMode == Transaction.WRITE)
+        {
+            // signal ObjectEnvelope that a WRITE lock is already acquired
+            envelope.setWriteLocked(true);
         }
     }
 
@@ -978,7 +1001,7 @@
      * reference locking, we will materialize objects and they will enter the registered for
      * lock map.
      */
-    private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException
+    private void internalLockRegisterReferences(final ClassDescriptor cld, final Object sourceObject, final int lockMode, final boolean cascade) throws LockNotGrantedException
     {
         if (implicitLocking)
         {
@@ -992,16 +1015,13 @@
                 {
                     boolean isProxy = proxyFactory.isProxy(refObj);
                     RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this);
-                    if (!registrationList.contains(rt.getIdentity()))
-                    {
-                        lockAndRegister(rt, lockMode, registeredObjects);
-                    }
+                    internalLockRegister(rt, lockMode, cascade);
                 }
             }
         }
     }
 
-    private void lockAndRegisterCollections(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException
+    private void internalLockRegisterCollections(final ClassDescriptor cld, final Object sourceObject, final int lockMode, boolean cascade) throws LockNotGrantedException
     {
         if (implicitLocking)
         {
@@ -1037,7 +1057,7 @@
                                 IndirectionHandler handler = proxyFactory.getIndirectionHandler(item);
                                 if (!handler.alreadyMaterialized())
                                 {
-                                    handler.addListener(this);
+                                    registerToIndirectionHandler(handler);
                                     continue;
                                 }
                                 else
@@ -1047,10 +1067,7 @@
                                     item = handler.getRealSubject();
                                 }
                             }
-                            if (!registrationList.contains(rt.getIdentity()))
-                            {
-                                lockAndRegister(rt, lockMode, registeredObjects);
-                            }
+                            internalLockRegister(rt, lockMode, cascade);
                         }
                     }
                     catch (LockNotGrantedException e)
@@ -1105,7 +1122,7 @@
             }
             ClassDescriptor cld = getBroker().getClassDescriptor(materializedObject.getClass());
             RuntimeObject rt = new RuntimeObject(getBrokerInternal(), materializedObject, oid, cld, false, false);
-            lockAndRegister(rt, Transaction.READ, false, getRegistrationList());
+            lockAndRegister(rt, Transaction.READ, isImplicitLocking());
         }
         catch (Throwable t)
         {
@@ -1152,12 +1169,46 @@
     }
 
     /**
-     * register proxy objects that were locked but haven't been materialized yet
-     * so they can be unlocked when closing the transaction
+     * Lock unmaterialized proxy objects -
+     *
+     * @param rtObj The unmaterialized proxy.
+     * @param lockMode The lock mode.
      */
-    protected void registerUnmaterializedLocks(Object obj)
+    private void lockUnmaterializedObject(final RuntimeObject rtObj, final int lockMode, final IndirectionHandler handler)
     {
-        unmaterializedLocks.add(obj);
+        registerToIndirectionHandler(handler);
+        // TODO: remove this section when deprecated locking classes are removed
+        if(!(getImplementation().getLockManager() instanceof LockManagerOdmgImpl))
+        {
+            unmaterializedLocks.add(rtObj);
+        }
+        if(log.isDebugEnabled()) log.debug("Lock unmaterialized proxy object: " + rtObj.getIdentity());
+        internalSingleLock(rtObj.getCld(), rtObj.getIdentity(), lockMode);
+    }
+
+    /**
+     * For internal use! For backward compatibility with older
+     * locking implementations. This methods releases all locks for
+     * unmaterialized objects which are not registered in {@link ObjectEnvelopeTable}.
+     * The new lock implementation fully supports methods
+     * {@link org.apache.ojb.odmg.locking.LockManager#releaseLocks(org.apache.ojb.odmg.TransactionImpl)}
+     * the old ones need this method.
+     *
+     * @deprecated will be removed
+     */
+    public void releaseUnmaterialzedLocks()
+    {
+        // TODO: remove this method when deprecated locking classes are removed
+        LockManager lm = getImplementation().getLockManager();
+        if(!(lm instanceof LockManagerOdmgImpl) && unmaterializedLocks.size() > 0)
+        {
+            //remove locks for objects which haven't been materialized yet
+            for (Iterator it = unmaterializedLocks.iterator(); it.hasNext();)
+            {
+                RuntimeObject rt = (RuntimeObject) it.next();
+                lm.releaseLock(this, rt.getIdentity());
+            }
+        }
     }
 
     /**
@@ -1168,12 +1219,13 @@
      * very good chance the broker will be leaked as the doClose() method of
      * transactionImpl will never be called and thus the broker will never
      * be closed and returned to the pool.
+     *
      * @return Returns a PersistenceBroker
      * @throws TransactionNotInProgressException is the transaction is not open;
      */
     public PersistenceBrokerInternal getBrokerInternal()
     {
-        if (broker == null || broker.isClosed())
+        if (broker == null)
         {
             checkOpen();
             try
@@ -1201,7 +1253,7 @@
      */
     protected boolean hasBroker()
     {
-        return broker != null && !broker.isClosed();
+        return broker != null; //&& !broker.isClosed();
     }
 
     protected void cleanupBroker()
@@ -1271,7 +1323,7 @@
                 Identity oid = broker.serviceIdentity().buildIdentity(o);
                 ClassDescriptor cld = broker.getClassDescriptor(broker.getProxyFactory().getRealClass(o));
                 RuntimeObject rt = new RuntimeObject(broker, o, oid, cld, false, broker.getProxyFactory().isProxy(o));
-                lockAndRegister(rt, Transaction.READ, false, getRegistrationList());
+                lockAndRegister(rt, Transaction.READ, isImplicitLocking());
             }
         }
         unregisterFromCollectionProxy(colProxy);
@@ -1335,6 +1387,52 @@
     }
 
     /**
+     * Detect new objects.
+     */
+    protected boolean isTransient(ClassDescriptor cld, Object obj, Identity oid)
+    {
+        // if the Identity is transient we assume a non-persistent object
+        boolean isNew = oid != null && oid.isTransient();
+        /*
+        detection of new objects is costly (select of ID in DB to check if object
+        already exists) we do:
+        a. check if the object has nullified PK field
+        b. check if the object is already registered
+        c. lookup from cache and if not found, last option select on DB
+        */
+        if(!isNew)
+        {
+            final PersistenceBroker pb = getBroker();
+            if(cld == null)
+            {
+                cld = pb.getClassDescriptor(obj.getClass());
+            }
+            isNew = pb.serviceBrokerHelper().hasNullPKField(cld, obj);
+            if(!isNew)
+            {
+                if(oid == null)
+                {
+                    oid = pb.serviceIdentity().buildIdentity(cld, obj);
+                }
+                final ObjectEnvelope mod = objectEnvelopeTable.getByIdentity(oid);
+                if(mod != null)
+                {
+                    // already registered object, use current state
+                    isNew = mod.needsInsert();
+                }
+                else
+                {
+                    // if object was found cache, assume it's old
+                    // else make costly check against the DB
+                    isNew = pb.serviceSessionCache().lookup(oid, SessionCache.LEVEL_DEEP) == null
+                            && !pb.serviceJdbcAccess().doesExist(cld, oid);
+                }
+            }
+        }
+        return isNew;
+    }
+
+    /**
      * Allows to change the <em>cascading delete</em> behavior of the specified reference
      * of the target class while this transaction is in use.
      *
@@ -1360,7 +1458,9 @@
 
     /**
      * Allows to change the <em>cascading delete</em> behavior of all references of the
-     * specified class while this transaction is in use.
+     * specified class while this transaction is in use - if the specified class is an
+     * interface, abstract class or class with "extent" classes the cascading flag will
+     * be propagated.
      *
      * @param target The class to change cascading delete behavior of all references.
      * @param doCascade If <em>true</em> cascading delete is enabled, <em>false</em> disabled.
@@ -1368,18 +1468,33 @@
     public void setCascadingDelete(Class target, boolean doCascade)
     {
         ClassDescriptor cld = getBroker().getClassDescriptor(target);
+        List extents = cld.getExtentClasses();
         Boolean result = doCascade ? Boolean.TRUE : Boolean.FALSE;
+        setCascadingDelete(cld, result);
+        if(extents != null && extents.size() > 0)
+        {
+            for(int i = 0; i < extents.size(); i++)
+            {
+                Class extent =  (Class) extents.get(i);
+                ClassDescriptor tmp = getBroker().getClassDescriptor(extent);
+                setCascadingDelete(tmp, result);
+            }
+        }
+    }
+
+    private void setCascadingDelete(ClassDescriptor cld, Boolean cascade)
+    {
         List singleRefs = cld.getObjectReferenceDescriptors(true);
         for(int i = 0; i < singleRefs.size(); i++)
         {
             Object o = singleRefs.get(i);
-            runtimeCascadeDeleteMap.put(o, result);
+            runtimeCascadeDeleteMap.put(o, cascade);
         }
         List collectionRefs = cld.getCollectionDescriptors(true);
         for(int i = 0; i < collectionRefs.size(); i++)
         {
             Object o =  collectionRefs.get(i);
-            runtimeCascadeDeleteMap.put(o, result);
+            runtimeCascadeDeleteMap.put(o, cascade);
         }
     }
 
@@ -1398,27 +1513,6 @@
             arminw: Here we use the auto-delete flag defined in metadata
             */
             result = ord.getCascadingDelete() == ObjectReferenceDescriptor.CASCADE_OBJECT;
-/*
-arminw:
-these settings are nonsense (my fault), it dosen't make sense to differ cascade delete
-on the used reference type.
-*/
-//            if(ord instanceof CollectionDescriptor)
-//            {
-//                CollectionDescriptor cds = (CollectionDescriptor) ord;
-//                if(cds.isMtoNRelation())
-//                {
-//                    result = implementation.cascadingDeleteMtoN;
-//                }
-//                else
-//                {
-//                    result = implementation.cascadingDeleteOnetoN;
-//                }
-//            }
-//            else
-//            {
-//                result = implementation.cascadingDeleteOnetoOne;
-//            }
         }
         else
         {
@@ -1456,33 +1550,30 @@
         this.ordering = ordering;
     }
 
-    /**
-     * @see ImplementationExt#isNoteUserOrder()
-     */
-    public boolean isNoteUserOrder()
+    protected void finalize() throws Throwable
     {
-        return noteUserOrdering;
-    }
-
-    /**
-     * @see ImplementationExt#setNoteUserOrder(boolean)
-     */
-    public void setNoteUserOrder(boolean noteUserOrder)
-    {
-        this.noteUserOrdering = noteUserOrder;
+        super.finalize();
+        if(isOpen())
+        {
+            log.error("Finalize object: This transaction is still marked as active, please check code" +
+                    " for tx leaks: " + this.toString());
+            try
+            {
+                this.abort();
+            }
+            catch(Exception ignore)
+            {
+                // ignore
+            }
+        }
     }
 
-    /**
-     * Move the specified {@link org.apache.ojb.broker.Identity} to the
-     * last position in the order list if {@link #isNoteUserOrder()} returns <em>true</em>.
-     * @param oid The object identity to move.
-     */
-    public void moveToLastInOrderList(Identity oid)
+    public String toString()
     {
-        if(isNoteUserOrder())
-        {
-            objectEnvelopeTable.moveToLastInOrderList(oid);
-        }
+        return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
+                .append("tx-status", TxUtil.getStatusString(getStatus()))
+                .append("unclosed_broker", this.broker != null && !broker.isClosed())
+                .toString();
     }
 
     //============================================================

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/TxUtil.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/TxUtil.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/TxUtil.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/TxUtil.java Sat Jul 15 07:28:03 2006
@@ -1,8 +1,6 @@
 package org.apache.ojb.odmg;
 
-import javax.transaction.Status;
-
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+import javax.transaction.Status;
+
 public class TxUtil
 {
     public static String getStatusString(int status)

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java Sat Jul 15 07:28:03 2006
@@ -20,7 +20,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import org.apache.ojb.broker.ManageableCollection;
 import org.apache.ojb.broker.PersistenceBroker;
@@ -125,7 +125,7 @@
         }
     }
 
-    private Vector flatten(Criteria crit, Vector acc)
+    private List flatten(final Criteria crit, final List acc)
     {
         Enumeration e = crit.getElements();
         while (e.hasMoreElements())
@@ -164,12 +164,12 @@
      * @param	queryString	An OQL query.
      * @exception	QueryInvalidException	The query syntax is invalid.
      */
-    public void create(String queryString) throws org.odmg.QueryInvalidException
+    public void create(final String queryString) throws org.odmg.QueryInvalidException
     {
         create(queryString, Query.NO_START_AT_INDEX, Query.NO_END_AT_INDEX);
     }
 
-    public void create(String queryString, int startAtIndex, int endAtIndex) throws QueryInvalidException
+    public void create(final String queryString, final int startAtIndex, final int endAtIndex) throws QueryInvalidException
     {
         if (log.isDebugEnabled()) log.debug("create query for query-string: " + queryString);
         /**
@@ -191,12 +191,12 @@
         {
 //			Query query = QueryPool.getQuery(queryString);
             // Use the OQL parser to transform a query string to a valid org.apache.ojb.broker.query object
-            QueryByCriteria _query;
-            StringReader reader = new StringReader(queryString);
-            OQLLexer lexer = new OQLLexer(reader);
-            OQLParser parser = new OQLParser(lexer);
+            final QueryByCriteria _query;
+            final StringReader reader = new StringReader(queryString);
+            final OQLLexer lexer = new OQLLexer(reader);
+            final OQLParser parser = new OQLParser(lexer);
             _query = (QueryByCriteria) parser.buildQuery();
-            setBindIterator(flatten(_query.getCriteria(), new Vector()).listIterator());
+            setBindIterator(flatten(_query.getCriteria(), new ArrayList()).listIterator());
             _query.setStartAtIndex(startAtIndex);
             _query.setEndAtIndex(endAtIndex);
             setQuery(_query);
@@ -255,9 +255,8 @@
             }
             else
             {
-                Iterator iter;
                 result = broker.getConfiguration().getCollectionFactory().createCollection(this, null);
-                iter = broker.getReportQueryIteratorByQuery(query);
+                Iterator iter = broker.getReportQueryIteratorByQuery(query);
                 try
                 {
                     while (iter.hasNext())
@@ -319,20 +318,12 @@
         {
             // read-lock all resulting objects to the current transaction
             Iterator iter = result.ojbIterator(broker);
-            Object toBeLocked = null;
-            try
+            Object toBeLocked;
+            while (iter.hasNext())
             {
-                List regList = tx.getRegistrationList();
-                while (iter.hasNext())
-                {
-                    toBeLocked = iter.next();
-                    RuntimeObject rt = new RuntimeObject(toBeLocked, tx, false);
-                    tx.lockAndRegister(rt, Transaction.READ, true, regList);
-                }
-            }
-            finally
-            {
-                tx.clearRegistrationList();
+                toBeLocked = iter.next();
+                RuntimeObject rt = new RuntimeObject(toBeLocked, tx, false);
+                tx.lockAndRegister(rt, Transaction.READ, true);
             }
         }
     }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/ModificationState.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/ModificationState.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/ModificationState.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/ModificationState.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
 /**
  * Describes an objects transactional state regarding commiting and rollbacking
  */
-public abstract class ModificationState extends Object implements Serializable
+public abstract class ModificationState implements Serializable
 {
 	static final long serialVersionUID = 4182870857709997816L;
     public ModificationState()
@@ -107,5 +107,30 @@
     public boolean needsDelete()
     {
         return false;
+    }
+
+    public boolean isTransient()
+    {
+        return false;
+    }
+
+    public boolean isNew()
+    {
+        return false;
+    }
+
+    public boolean isDirty()
+    {
+        return false;
+    }
+
+    public boolean isDelete()
+    {
+        return false;
+    }
+
+    public boolean isClean()
+    {
+        return !isDelete() && !isDirty();
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewClean.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewClean.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewClean.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewClean.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -113,5 +113,10 @@
     public void rollback(ObjectEnvelope mod)
     {
         mod.doEvictFromCache();
+    }
+
+    public boolean isNew()
+    {
+        return true;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDelete.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDelete.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDelete.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDelete.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 import org.apache.ojb.odmg.ObjectEnvelope;
 
 /**
- * this state represents new objects which have been mrked for deletion during tx.
+ * this state represents new objects which have been marked for deletion during tx.
  */
 public class StateNewDelete extends ModificationState
 {
@@ -111,5 +111,15 @@
     {
         mod.doEvictFromCache();
         mod.setModificationState(StateTransient.getInstance());
+    }
+
+    public boolean isNew()
+    {
+        return true;
+    }
+
+    public boolean isDelete()
+    {
+        return true;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDirty.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDirty.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDirty.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateNewDirty.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
  */
 
 import org.apache.ojb.odmg.ObjectEnvelope;
+import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
  * This state represents new objects which have been altered during tx.
@@ -91,8 +92,7 @@
     /**
      * checkpoint the ObjectModification
      */
-    public void checkpoint(ObjectEnvelope mod)
-            throws org.apache.ojb.broker.PersistenceBrokerException
+    public void checkpoint(ObjectEnvelope mod) throws PersistenceBrokerException
     {
         mod.doInsert();
         mod.setModificationState(StateOldClean.getInstance());
@@ -101,7 +101,7 @@
     /**
      * commit the associated transaction
      */
-    public void commit(ObjectEnvelope mod) throws org.apache.ojb.broker.PersistenceBrokerException
+    public void commit(ObjectEnvelope mod) throws PersistenceBrokerException
     {
         mod.doInsert();
         mod.setModificationState(StateOldClean.getInstance());
@@ -116,4 +116,13 @@
         mod.doEvictFromCache();
     }
 
+    public boolean isNew()
+    {
+        return true;
+    }
+
+    public boolean isDirty()
+    {
+        return true;
+    }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldClean.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldClean.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldClean.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldClean.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDelete.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDelete.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDelete.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDelete.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,5 +114,10 @@
     public void rollback(ObjectEnvelope mod)
     {
         mod.doEvictFromCache();
+    }
+    
+    public boolean isDelete()
+    {
+        return true;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDirty.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDirty.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDirty.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateOldDirty.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -122,4 +122,8 @@
         return true;
     }
 
+    public boolean isDirty()
+    {
+        return true;
+    }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateTransient.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateTransient.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateTransient.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/odmg/states/StateTransient.java Sat Jul 15 07:28:03 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.odmg.states;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.odmg.ObjectEnvelope;
+import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
  * this state represents objects which are not persisted and no longer used.
@@ -108,5 +108,10 @@
      */
     public void rollback(ObjectEnvelope mod)
     {
+    }
+
+    public boolean isTransient()
+    {
+        return true;
     }
 }

Modified: db/ojb/trunk/src/java/org/odmg/Implementation.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/odmg/Implementation.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/odmg/Implementation.java (original)
+++ db/ojb/trunk/src/java/org/odmg/Implementation.java Sat Jul 15 07:28:03 2006
@@ -39,7 +39,7 @@
      * @return The new <code>OQLQuery</code> object.
      * @see org.odmg.OQLQuery
      */
-    public EnhancedOQLQuery newOQLQuery();
+    public OQLQuery newOQLQuery();
 
     /**
      * Create a new <code>DList</code> object.

Modified: db/ojb/trunk/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java (original)
+++ db/ojb/trunk/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java Sat Jul 15 07:28:03 2006
@@ -25,7 +25,7 @@
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceConfiguration;
-import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
+import org.apache.ojb.broker.util.ObjectModification;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 
@@ -93,7 +93,7 @@
             logger.debug("OjbStoreManager.insert");
             PersistenceBroker broker = connector.getBroker();
             Object instance = sm.getObject();
-            broker.store(instance, ObjectModificationDefaultImpl.INSERT);
+            broker.store(instance, ObjectModification.INSERT);
         }
         catch (Exception ex)
         {
@@ -118,7 +118,7 @@
             PersistenceBroker broker = connector.getBroker();
             fetch(sm, null);
             Object instance = sm.getObject();
-            broker.store(instance, ObjectModificationDefaultImpl.UPDATE);
+            broker.store(instance, ObjectModification.UPDATE);
         }
         catch (Exception ex)
         {

Modified: db/ojb/trunk/src/samples/org/apache/ojb/tutorials/PBExample.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/samples/org/apache/ojb/tutorials/PBExample.java?rev=422235&r1=422234&r2=422235&view=diff
==============================================================================
--- db/ojb/trunk/src/samples/org/apache/ojb/tutorials/PBExample.java (original)
+++ db/ojb/trunk/src/samples/org/apache/ojb/tutorials/PBExample.java Sat Jul 15 07:28:03 2006
@@ -198,7 +198,7 @@
 
                 broker.store(result);
                 // alternative, more performant:
-                // broker.store(result, ObjectModificationDefaultImpl.UPDATE);
+                // broker.store(result, ObjectModification.UPDATE);
 
                 broker.commitTransaction();
                 isSold = true;



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message