db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r469569 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: ./ accesslayer/ cache/ core/ locking/ metadata/ metadata/fieldaccess/ util/ util/sequence/
Date Tue, 31 Oct 2006 17:21:34 GMT
Author: arminw
Date: Tue Oct 31 09:21:32 2006
New Revision: 469569

URL: http://svn.apache.org/viewvc?view=rev&rev=469569
Log:
performance improvements

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/DelegatingPersistenceBroker.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/MtoNBroker.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java Tue Oct 31 09:21:32 2006
@@ -66,12 +66,24 @@
      * Deletes the persistence representation of the given object in the underlying
      * persistence system. This method is intended for use in top-level apis internally.
      *
-     * @param obj              The object to delete
+     * @param obj The object to delete.
      * @param ignoreReferences Whether automatic deletion of contained references/collections (except
-     *                         super-references) shall be suppressed (independent of the auto-delete
-     *                         setting in the metadata)
+     * super-references) shall be suppressed (independent of the auto-delete setting in the metadata).
      */
     public void delete(Object obj, boolean ignoreReferences) throws PersistenceBrokerException;
+
+    /**
+     * Deletes the persistence representation of the given object in the underlying
+     * persistence system. This method is intended for use in top-level apis internally.
+     *
+     * @param obj The object to delete.
+     * @param oid The {@link Identity} of the object.
+     * @param cld The {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the object to delete.
+     * @param ignoreReferences Whether automatic deletion of contained references/collections (except
+     * super-references) shall be suppressed (independent of the auto-delete setting in the metadata).
+     */
+    public void delete(Object obj, Identity oid, ClassDescriptor cld , boolean ignoreReferences)
+            throws PersistenceBrokerException;
 
     /**
      * Returns the broker specifically for retrieving references via query.

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java Tue Oct 31 09:21:32 2006
@@ -23,11 +23,9 @@
 import java.util.Map;
 
 import org.apache.ojb.broker.Identity;
-import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.cache.ObjectCache;
 import org.apache.ojb.broker.core.PersistenceBrokerImpl;
 import org.apache.ojb.broker.core.proxy.IndirectionHandler;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.query.Query;
 
 /**
@@ -56,7 +54,7 @@
 
     protected void associateBatched(Collection proxies, Collection realSubjects)
     {
-        PersistenceBroker pb = getBroker();
+        PersistenceBrokerImpl pb = getBroker();
         IndirectionHandler handler;
         Identity id;
         Object proxy;
@@ -72,7 +70,7 @@
         for (Iterator it = proxies.iterator(); it.hasNext(); )
         {
             proxy = it.next();
-            handler = ProxyHelper.getIndirectionHandler(proxy);
+            handler = pb.getProxyFactory().getIndirectionHandler(proxy);
 
             if (handler == null)
             {
@@ -103,13 +101,13 @@
         Class realClass;
         HashMap classToIds = new HashMap();
         Class topLevelClass = getItemClassDescriptor().getClassOfObject();
-        PersistenceBroker pb = getBroker();
+        PersistenceBrokerImpl pb = getBroker();
         ObjectCache cache = pb.serviceObjectCache();
 
         for (Iterator it = proxies.iterator(); it.hasNext(); )
         {
             proxy = it.next();
-            handler = ProxyHelper.getIndirectionHandler(proxy);
+            handler = pb.getProxyFactory().getIndirectionHandler(proxy);
 
             if (handler == null)
             {

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java Tue Oct 31 09:21:32 2006
@@ -20,6 +20,7 @@
 import java.lang.ref.SoftReference;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
@@ -29,7 +30,6 @@
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.core.DelegatingPersistenceBroker;
 import org.apache.ojb.broker.core.PersistenceBrokerImpl;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.FieldDescriptor;
 import org.apache.ojb.broker.metadata.MetadataException;
@@ -280,9 +280,9 @@
      */
     private void pushToApplicationCache(int typeToProcess, int typeAfterProcess)
     {
-        for(Iterator iter = sessionCache.values().iterator(); iter.hasNext();)
+        for(Iterator iter = sessionCache.entrySet().iterator(); iter.hasNext();)
         {
-            CacheEntry entry = (CacheEntry) iter.next();
+            CacheEntry entry = (CacheEntry) ((Map.Entry) iter.next()).getValue();
             // if the cached object was garbage collected, nothing to do
             Object result = entry.get();
             if(result == null)
@@ -303,9 +303,9 @@
                     arminw:
                     only cache non-proxy or real subject of materialized proxy objects
                     */
-                    if(ProxyHelper.isMaterialized(result))
+                    if(broker.getProxyFactory().isMaterialized(result))
                     {
-                        putToApplicationCache(entry.oid, ProxyHelper.getRealObject(result), false);
+                        putToApplicationCache(entry.oid, broker.getProxyFactory().getRealObject(result), false);
                         // set the new type after the object was pushed to application cache
                         entry.type = typeAfterProcess;
                     }
@@ -674,13 +674,8 @@
                 // if first time put in cache write all fields, else only non-PK
                 if(!old || !fld.isPrimaryKey())
                 {
-                    // get the value
-                    Object value = fld.getPersistentField().get(obj);
-                    // convert value to a supported sql type, because we only
-                    // can copy this type
-                    value = fld.getFieldConversion().javaToSql(value);
-                    // copy the sql type
-                    value = fld.getJdbcType().getFieldType().copy(value);
+                    // get sql-type based copy of the value
+                    Object value = fld.getCopyOfValue(obj);
                     target.put(fld.getPersistentField().getName(), value);
                 }
             }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/DelegatingPersistenceBroker.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/DelegatingPersistenceBroker.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/DelegatingPersistenceBroker.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/DelegatingPersistenceBroker.java Tue Oct 31 09:21:32 2006
@@ -163,6 +163,11 @@
         m_broker.delete(obj, ignoreReferences);
     }
 
+    public void delete(Object obj, Identity oid, ClassDescriptor cld, boolean ignoreReferences) throws PersistenceBrokerException
+    {
+        m_broker.delete(obj, oid, cld, ignoreReferences);
+    }
+
     public boolean isInTransaction() throws PersistenceBrokerException
     {
         return m_broker != null && getBroker().isInTransaction();

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java Tue Oct 31 09:21:32 2006
@@ -27,8 +27,8 @@
 import org.apache.ojb.broker.PBStateListener;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerException;
+import org.apache.ojb.broker.PersistenceBrokerInternal;
 import org.apache.ojb.broker.core.proxy.IndirectionHandler;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
 import org.apache.ojb.broker.metadata.FieldDescriptor;
@@ -44,14 +44,15 @@
  */
 public class IdentityFactoryImpl implements IdentityFactory, PBStateListener
 {
-    private PersistenceBroker broker;
+    private PersistenceBrokerInternal broker;
     //private final Map persistentIdentityMap;
     private final Map transientIdentityMap;
     private final SequenceManager transientSequenceManager;
 
     public IdentityFactoryImpl(PersistenceBroker broker)
     {
-        this.broker = broker;
+        // todo: remove cast, change constructor
+        this.broker = (PersistenceBrokerInternal) broker;
         this.transientIdentityMap = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD, false);
         /*
         TODO: Introduce cache for persistent object Identity objects, as long as user can use the direct
@@ -63,7 +64,7 @@
         doesn't improve performance.
         */
         //this.persistentIdentityMap = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD, true);
-        this.transientSequenceManager = new SequenceManagerTransientImpl(broker);
+        this.transientSequenceManager = new SequenceManagerTransientImpl(broker, null);
         broker.addListener(this, true);
     }
 
@@ -86,7 +87,7 @@
         Object[] pks = null;
         try
         {
-            final IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objOrProxy);
+            final IndirectionHandler handler = broker.getProxyFactory().getIndirectionHandler(objOrProxy);
             if(handler != null)
             {
                 result = handler.getIdentity();

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/MtoNBroker.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/MtoNBroker.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/MtoNBroker.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/MtoNBroker.java Tue Oct 31 09:21:32 2006
@@ -15,22 +15,21 @@
  * limitations under the License.
  */
 
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import java.sql.SQLException;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.ojb.broker.MtoNImplementor;
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.PersistenceBrokerSQLException;
 import org.apache.ojb.broker.accesslayer.ResultSetAndStatement;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.CollectionDescriptor;
 import org.apache.ojb.broker.metadata.DescriptorRepository;
@@ -43,11 +42,6 @@
 /**
  * Manage all stuff related to non-decomposed M:N association.
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
- * @author <a href="mailto:leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz<a>
- * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird<a>
- * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  * @version $Id$
  */
 public class MtoNBroker
@@ -86,7 +80,7 @@
         ValueContainer[] pkValues = pb.serviceBrokerHelper().getKeyValues(cld, realObject);
         String[] pkColumns = cod.getFksToThisClass();
 
-        ClassDescriptor otherCld = pb.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(otherObj));
+        ClassDescriptor otherCld = pb.getDescriptorRepository().getDescriptorFor(pb.getProxyFactory().getRealClass(otherObj));
         ValueContainer[] otherPkValues = pb.serviceBrokerHelper().getKeyValues(otherCld, otherObj);
 
         String[] otherPkColumns = cod.getFksToItemClass();

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java Tue Oct 31 09:21:32 2006
@@ -566,7 +566,23 @@
         doTxCheck();
         try
         {
-            doDelete(obj, ignoreReferences);
+            ClassDescriptor cld = getClassDescriptor(getProxyFactory().getRealClass(obj));
+            Identity oid = serviceIdentity().buildIdentity(cld, obj);
+            doDelete(obj, oid, cld, ignoreReferences);
+        }
+        finally
+        {
+            markedForDelete.clear();
+        }
+    }
+
+    public void delete(Object obj, Identity oid, ClassDescriptor cld, boolean ignoreReferences)
+            throws PersistenceBrokerException
+    {
+        doTxCheck();
+        try
+        {
+            doDelete(obj, oid, cld, ignoreReferences);
         }
         finally
         {
@@ -586,62 +602,57 @@
      * do delete given object. Should be used by all intern classes to delete
      * objects.
      */
-    private void doDelete(Object obj, boolean ignoreReferences) throws PersistenceBrokerException
+    private void doDelete(Object obj, Identity oid, ClassDescriptor cld, boolean ignoreReferences)
+            throws PersistenceBrokerException
     {
-        //logger.info("DELETING " + obj);
-        // object is not null
-        if (obj != null)
-        {
-            // replace specified object with the real one
-            obj = getProxyFactory().getRealObject(obj);
-
-            /*
-            MBAIRD
-            1. if we are marked for delete already, avoid recursing on this object
-            arminw:
-            use object identity based list, because using objects we get a
-            better performance. I can't find side-effects in doing so.
-            */
-            if (markedForDelete.contains(obj))
-            {
-                return;
-            }
-
-            ClassDescriptor cld = getClassDescriptor(obj.getClass());
-            Identity oid = serviceIdentity().buildIdentity(cld, obj);
+        // replace specified object with the real one
+        obj = getProxyFactory().getRealObject(obj);
+        if(cld == null) cld = getClassDescriptor(obj.getClass());
+        if(oid == null) oid = serviceIdentity().buildIdentity(cld, obj);
+
+        /*
+        MBAIRD
+        1. if we are marked for delete already, avoid recursing on this object
+        arminw:
+        use object identity based list, because using objects we get a
+        better performance. I can't find side-effects in doing so.
+        */
+        if (markedForDelete.contains(obj))
+        {
+            return;
+        }
+
+        //BRJ: check for valid pk
+        //if (!serviceBrokerHelper().assertValidPkForDelete(cld, obj))
+        // TODO: arminw: this simple check should do the same - verify
+        if (oid.isTransient())
+        {
+            String msg = "Cannot delete object without valid PK's: " + obj;
+            logger.error(msg);
+            return;
+        }
+
+        /**
+         * MBAIRD
+         * 2. register object in markedForDelete map.
+         */
+        markedForDelete.add(obj);
+
+        // Invoke events on PersistenceBrokerAware instances and listeners
+        BEFORE_DELETE_EVENT.setTarget(obj);
+        fireBrokerEvent(BEFORE_DELETE_EVENT);
+        BEFORE_DELETE_EVENT.setTarget(null);
+
+        // now perform deletion
+        performDeletion(cld, obj, oid, ignoreReferences);
+
+        // Invoke events on PersistenceBrokerAware instances and listeners
+        AFTER_DELETE_EVENT.setTarget(obj);
+        fireBrokerEvent(AFTER_DELETE_EVENT);
+        AFTER_DELETE_EVENT.setTarget(null);
 
-            //BRJ: check for valid pk
-            //if (!serviceBrokerHelper().assertValidPkForDelete(cld, obj))
-            // TODO: arminw: this simple check should do the same - verify
-            if (oid.isTransient())
-            {
-                String msg = "Cannot delete object without valid PK's: " + obj;
-                logger.error(msg);
-                return;
-            }
-
-            /**
-             * MBAIRD
-             * 2. register object in markedForDelete map.
-             */
-            markedForDelete.add(obj);
-
-            // Invoke events on PersistenceBrokerAware instances and listeners
-            BEFORE_DELETE_EVENT.setTarget(obj);
-            fireBrokerEvent(BEFORE_DELETE_EVENT);
-            BEFORE_DELETE_EVENT.setTarget(null);
-
-            // now perform deletion
-            performDeletion(cld, obj, oid, ignoreReferences);
-
-            // Invoke events on PersistenceBrokerAware instances and listeners
-            AFTER_DELETE_EVENT.setTarget(obj);
-            fireBrokerEvent(AFTER_DELETE_EVENT);
-            AFTER_DELETE_EVENT.setTarget(null);
-
-            // let the connection manager to execute batch
-            connectionManager.executeBatchIfNecessary();
-        }
+        // let the connection manager to execute batch
+        connectionManager.executeBatchIfNecessary();
     }
 
     /**
@@ -802,7 +813,7 @@
                     }
                     else
                     {
-                        doDelete(referencedObject, ignoreReferences);
+                        doDelete(referencedObject, null, null, ignoreReferences);
                     }
                 }
             }
@@ -847,7 +858,7 @@
                         Iterator colIterator = BrokerHelper.getCollectionIterator(col);
                         while (colIterator.hasNext())
                         {
-                            doDelete(colIterator.next(), false);
+                            doDelete(colIterator.next(), null, null, false);
                         }
                     }
                 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java Tue Oct 31 09:21:32 2006
@@ -37,7 +37,6 @@
 import org.apache.ojb.broker.core.proxy.CollectionProxyListener;
 import org.apache.ojb.broker.core.proxy.IndirectionHandler;
 import org.apache.ojb.broker.core.proxy.MaterializationListener;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
 import org.apache.ojb.broker.metadata.CollectionDescriptor;
@@ -134,7 +133,7 @@
                  */
                 if (candidate != null)
                 {
-                    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(candidate);
+                    IndirectionHandler handler = pb.getProxyFactory().getIndirectionHandler(candidate);
 
                     if ((handler != null) || itemClass.isAssignableFrom(candidate.getClass()))
                     {
@@ -398,7 +397,7 @@
                             && (m_retrievalTasks != null)
                             && (rds.getProxyPrefetchingLimit() > 0))
                     {
-                        IndirectionHandler handler = ProxyHelper.getIndirectionHandler(refObj);
+                        IndirectionHandler handler = pb.getProxyFactory().getIndirectionHandler(refObj);
 
                         if ((handler != null)
                                 && addRetrievalTask(obj, rds))
@@ -448,7 +447,7 @@
                         && (m_retrievalTasks != null)
                         && (rds.getProxyPrefetchingLimit() > 0))
                 {
-                    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(refObj);
+                    IndirectionHandler handler = pb.getProxyFactory().getIndirectionHandler(refObj);
 
                     if ((handler != null)
                             && addRetrievalTask(obj, rds))
@@ -742,7 +741,7 @@
                     if (prefetchProxies && (m_retrievalTasks != null)
                             && (cds.getProxyPrefetchingLimit() > 0)
                             && (cds.getQueryCustomizer() == null)
-                            && (ProxyHelper.isCollectionProxy(value)))
+                            && (pb.getProxyFactory().isCollectionProxy(value)))
                     {
                         if (addRetrievalTask(obj, cds))
                         {
@@ -978,7 +977,7 @@
 
         protected void addThisListenerTo(Object owner)
         {
-            _listenedHandler = ProxyHelper.getIndirectionHandler(owner);
+            _listenedHandler = pb.getProxyFactory().getIndirectionHandler(owner);
 
             if (_listenedHandler != null)
             {

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java Tue Oct 31 09:21:32 2006
@@ -16,12 +16,12 @@
  */
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.collections.list.TreeList;
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.ojb.broker.util.configuration.Configurable;
@@ -383,7 +383,7 @@
         List list = (List) keyLockMap.get(key);
         if(list == null)
         {
-            list = new TreeList();
+            list = new ArrayList();
             keyLockMap.put(key, list);
         }
         if(!list.contains(lock)) list.add(lock);

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java Tue Oct 31 09:21:32 2006
@@ -57,7 +57,6 @@
  * ClassDescriptor instances, because instances could become invalid
  * during runtime (see {@link MetadataManager}).
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
  * @version $Id$
  */
 public final class ClassDescriptor extends DescriptorBase
@@ -1060,16 +1059,9 @@
             // 1. collect all Primary Key fields from Field list
             Vector vec = new Vector();
             // 1.a if descriptor describes an interface: take PK fields from an implementors ClassDescriptor
-            if (m_isInterface)
+            if (isInterface())
             {
-                if (getExtentClasses().size() == 0)
-                {
-                    throw new PersistenceBrokerException(
-                        "No Implementors declared for interface "
-                            + this.getClassOfObject().getName());
-                }
-                Class implementor = (Class) getExtentClasses().get(0);
-                ClassDescriptor implCld = this.getRepository().getDescriptorFor(implementor);
+                ClassDescriptor implCld = this.getRepository().findFirstConcreteClass(this);
                 m_PkFieldDescriptors = implCld.getPkFields();
             }
             else

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java Tue Oct 31 09:21:32 2006
@@ -32,7 +32,6 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
  * @version $Id$
  */
 public class CollectionDescriptor extends ObjectReferenceDescriptor
@@ -328,27 +327,32 @@
         {
             DescriptorRepository repo = getClassDescriptor().getRepository();
             ClassDescriptor cld = repo.getDescriptorFor(getItemClass());
-            if (cld.getProxyClass() != null)
-            {
-                m_hasProxyItems = Boolean.TRUE;
-            }
-            else
+            m_hasProxyItems = hasProxyItems(cld);
+        }
+
+        return m_hasProxyItems.booleanValue();
+    }
+
+    private static Boolean hasProxyItems(ClassDescriptor cld)
+    {
+        Boolean result = Boolean.FALSE;
+        if (cld.getProxyClass() != null)
+        {
+            result = Boolean.TRUE;
+        }
+        else if(cld.isExtent())
+        {
+            Collection extents = cld.getRepository().getAllConcreteSubclassDescriptors(cld);
+            for (Iterator it = extents.iterator(); it.hasNext(); )
             {
-                Collection extents = cld.getExtentClasses();
-                m_hasProxyItems = Boolean.FALSE;
-                for (Iterator it = extents.iterator(); it.hasNext(); )
+                ClassDescriptor ext = (ClassDescriptor) it.next();
+                if (ext.getProxyClass() != null)
                 {
-                    Class ext = (Class) it.next();
-                    ClassDescriptor cldExt = repo.getDescriptorFor(ext);
-                    if (cldExt.getProxyClass() != null)
-                    {
-                        m_hasProxyItems = Boolean.TRUE;
-                        break;
-                    }
+                    result = Boolean.TRUE;
+                    break;
                 }
             }
         }
-
-        return (m_hasProxyItems.booleanValue());
+        return result;
     }
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java Tue Oct 31 09:21:32 2006
@@ -24,8 +24,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Vector;
 
+import org.apache.commons.collections.set.ListOrderedSet;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
@@ -43,8 +43,6 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
- * @author <a href="mailto:leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz<a>
  * @version $Id$
  */
 public final class DescriptorRepository extends DescriptorBase
@@ -229,7 +227,7 @@
             "If you do not use the SELECT-list order to access data,
              then you can lose the stream data."
         */
-        List allFieldDescriptors = new Vector();
+        List allFieldDescriptors = new ArrayList();
 
         Set visitedColumns = new HashSet();
         Iterator it = classDescriptors.iterator();
@@ -343,11 +341,10 @@
     }
 
     /**
+     * Utility method to discover all concrete sub-classes {@link ClassDescriptor}
+     * of a given super class.
      *
-     * Utility method to discover all concrete subclasses of a given super class. <br>
-     * This method was introduced in order to get Extent Aware Iterators.
-     *
-     * @return a Collection of ClassDescriptor objects
+     * @return a collection of ClassDescriptor objects
      */
     public Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
     {
@@ -359,10 +356,8 @@
 
         if (concreteSubclassClds == null)
         {
-            // BRJ: As long as we do not have an ordered Set
-            // duplicates have to be prevented manually.
-            // a HashSet should not be used because the order is unpredictable
-            concreteSubclassClds = new ArrayList();
+            // BRJ: ListOrderedSet prevents duplicates and ensures the order.
+            concreteSubclassClds = new ListOrderedSet();
             Iterator iter = aCld.getExtentClasses().iterator();
 
             while (iter.hasNext())
@@ -376,10 +371,7 @@
                 }
                 if (!extCld.isInterface() && !extCld.isAbstract())
                 {
-                    if (!concreteSubclassClds.contains(extCld))
-                    {
-                        concreteSubclassClds.add(extCld);
-                    }
+                    concreteSubclassClds.add(extCld);
                 }
 
                 // recurse
@@ -387,10 +379,7 @@
                 while (subIter.hasNext())
                 {
                     ClassDescriptor subCld = (ClassDescriptor)subIter.next();
-                    if (!concreteSubclassClds.contains(subCld))
-                    {
-                        concreteSubclassClds.add(subCld);
-                    }
+                    concreteSubclassClds.add(subCld);
                 }
             }
             m_allConcreteSubClass.put(aCld.getClassOfObject(), concreteSubclassClds);
@@ -679,8 +668,7 @@
 
             if (result != null)
             {
-                // descriptorTable.put(clazz.getName(), result);
-                put(clazz, result);
+                descriptorTable.put(clazz.getName(), result);
             }
         }
         return result;

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Tue Oct 31 09:21:32 2006
@@ -41,7 +41,6 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
  * @version $Id$
  */
 public class FieldDescriptor extends AttributeDescriptorBase implements XmlCapable, Serializable
@@ -615,6 +614,27 @@
             val = broker.serviceLobHelper().wrapLobField(this, val);
         }
         return val;
+    }
+
+    /**
+     * Return a sql-type based copy of the value represented by this
+     * field. The value was transformed to the sql-type using
+     * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#javaToSql(Object)}
+     * and the copy is based on {@link FieldType#copy(Object)}).
+     *
+     * @param source The source object (normally the whole POJO)
+     * @return A sql-type based copy the value represented by this field.
+     */
+    public Object getCopyOfValue(final Object source)
+    {
+        // get the value
+        Object value = getPersistentField().get(source);
+        // convert value to a supported sql type, because we only
+        // can copy this type
+        value = getFieldConversion().javaToSql(value);
+        // copy the sql type
+        value = getJdbcType().getFieldType().copy(value);
+        return value;
     }
 
     /**

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java Tue Oct 31 09:21:32 2006
@@ -35,8 +35,7 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
- *
+ * @version $Id: $
  */
 public class ObjectReferenceDescriptor extends AttributeDescriptorBase implements XmlCapable
 {
@@ -115,13 +114,10 @@
             // In a many-to-many relationship Fk-Fields vector will be null.
             if (fkFields != null)
             {
-                if (targetCld.isInterface())
+                if (targetCld.isInterface() || targetCld.isAbstract())
                 {
                     //exchange interface class descriptor with first concrete class
-                    Vector extents = targetCld.getExtentClasses();
-                    // TODO: Check for side-effects
-                    Class firstConcreteClass = (Class) extents.get(0);
-                    targetCld = getClassDescriptor().getRepository().getDescriptorFor(firstConcreteClass);
+                    targetCld = targetCld.getRepository().findFirstConcreteClass(targetCld);
                 }
                 List ret = new ArrayList();
 
@@ -179,29 +175,25 @@
      */
 	public FieldDescriptor[] getForeignKeyFieldDescriptors(ClassDescriptor cld)
 	{
-		FieldDescriptor[] foreignKeyFieldDescriptors;
-		if ((foreignKeyFieldDescriptors = (FieldDescriptor[]) fkFieldMap.get(cld)) == null)
+		FieldDescriptor[] fkFieldDescriptors = (FieldDescriptor[]) fkFieldMap.get(cld);
+		if (fkFieldDescriptors == null)
 		{
-			// 1. collect vector of indices of Fk-Fields
-			Vector v = getForeignKeyFields();
-			// 2. get FieldDescriptor for each index from Class-descriptor
-			// 2A. In a many-to-many relationship foreignkeyfields vector will be null.
-			if (v != null)
+			// collect list of indices of Fk-Fields
+			List fkFields = getForeignKeyFields();
+
+			// get FieldDescriptor for each index from Class-descriptor
+			// In a many-to-many relationship fkFields list will be 'null'.
+			if (fkFields != null)
 			{
-				Vector ret;
-				if (cld.isInterface())
+				if (cld.isInterface() || cld.isAbstract())
 				{
 					//exchange interface class descriptor with first concrete class
-					Vector extents = cld.getExtentClasses();
-					Class firstConcreteClass = (Class) extents.get(0);
-					cld = getClassDescriptor().getRepository().getDescriptorFor(firstConcreteClass);
+					cld = cld.getRepository().findFirstConcreteClass(cld);
 				}
-				ret = new Vector();
-
-				Iterator iter = v.iterator();
-				while (iter.hasNext())
-				{
-                    ForeignKey fk = (ForeignKey) iter.next();
+				List ret = new ArrayList();
+				for (int i = 0; i < fkFields.size(); i++)
+                {
+                    ForeignKey fk = (ForeignKey) fkFields.get(i);
 					FieldDescriptor fkfd = null;
 					/*
                     OJB-55
@@ -238,11 +230,11 @@
 					}
 					ret.add(fkfd);
 				}
-				foreignKeyFieldDescriptors = (FieldDescriptor[]) ret.toArray(new FieldDescriptor[ret.size()]);
-				fkFieldMap.put(cld, foreignKeyFieldDescriptors);
+				fkFieldDescriptors = (FieldDescriptor[]) ret.toArray(new FieldDescriptor[ret.size()]);
+				fkFieldMap.put(cld, fkFieldDescriptors);
 			}
 		}
-		return foreignKeyFieldDescriptors;
+		return fkFieldDescriptors;
 	}
 
     /**
@@ -276,7 +268,7 @@
     }
 
     /**
-     *
+     * Answer the ItemClass.
      */
     public Class getItemClass()
     {
@@ -367,7 +359,6 @@
         }
         m_ForeignKeyFields.add(new ForeignKey(fkField, targetField, inverse));
     }
-
 
     /**
      * Gets the refresh.

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java Tue Oct 31 09:21:32 2006
@@ -15,17 +15,11 @@
  * limitations under the License.
  */
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Vector;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentField;
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
-import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 
@@ -43,7 +37,6 @@
     public static final String SUPER_FIELD_NAME = RepositoryElements.TAG_SUPER;
 
     private Boolean javaInheritance;
-    private Map declaredInheritanceFields = new HashMap();
 
     public SuperReferenceDescriptor(ClassDescriptor descriptor)
     {
@@ -157,8 +150,8 @@
     /**
      * If this method returns <em>true</em> the inheritance described by this object
      * is a <em>normal</em> JAVA inheritance. If <em>false</em> the inheritance is only declared
-     * in the O/R mapping it's a <em>declarative inheritance</em>, the referenced "super class" in <strong>not</strong>
-     * a JAVA super class of the main class.
+     * in the O/R mapping it's a <em>declarative inheritance</em>, the referenced
+     * "super class" in <strong>not</strong> a JAVA super class of the main class.
      */
     public boolean isJavaInheritance()
     {
@@ -170,32 +163,17 @@
         return javaInheritance.booleanValue();
     }
 
-    synchronized PersistentField getDeclaredInheritanceField(Class target, String name)
-    {
-        Map fields = (HashMap) declaredInheritanceFields.get(target);
-        if(fields == null)
-        {
-            fields = new HashMap();
-            declaredInheritanceFields.put(target, fields);
-        }
-        PersistentField pf = (PersistentField) fields.get(name);
-        if(pf == null)
-        {
-            pf = PersistentFieldFactory.createPersistentField(target, name);
-            // System.out.println("## tmp field: " + target + ", name: " + name + ", field: " + pf);
-            fields.put(name, pf);
-        }
-        return pf;
-    }
-
 
     //====================================================
     // inner class
     //====================================================
-
+    /**
+     * A {@link org.apache.ojb.broker.metadata.fieldaccess.PersistentField} implementation
+     * to handle "table-per-subclass"-inheritance.
+     */
     public static final class SuperReferenceField extends AnonymousPersistentField
     {
-        private Logger log = LoggerFactory.getLogger(SuperReferenceField.class);
+        // private Logger log = LoggerFactory.getLogger(SuperReferenceField.class);
 
         private SuperReferenceDescriptor superRef;
 
@@ -206,8 +184,7 @@
         }
 
         /**
-         * Field values of 'value' (base object) are copied to 'obj' (derived object)
-         * then obj is saved in a map
+         * A noop-method.
          *
          * @param target - the base object instance
          * @param value  - the derived object instance
@@ -215,214 +192,32 @@
          */
         public synchronized void set(Object target, Object value) throws MetadataException
         {
-            // System.out.println("target: " + target + " value: " + value);
-            ClassDescriptor superCld = superRef.getClassDescriptor().getSuperClassDescriptor();
-            if(superRef.isJavaInheritance())
-            {
-                copyFields(superCld, target, superCld, value);
-            }
-            else
+            //System.out.println("super.set: target=" + target + ", value=" + value);
+            //System.out.println(ExceptionHelper.buildExceptionStack("super.set: " + superRef));
+            if(!superRef.isJavaInheritance())
             {
                 throw new MetadataException("Declared super class '" + superRef.getClassDescriptor()
                         + "'is not assignable from " + target.getClass() + ". Reference: " + toString());
-                // copyFields(superRef.getClassDescriptor(), target, superCld, value, false, false);
             }
         }
 
         /**
-         * Field values of specified 'obj' (the derived object) are copied to
-         * 'value' (base object) then value is returned as a referenced object.
-         * If the base object is the super class of the specified 'obj', then
-         * return the specified object.
-         * Else a base class instance will be created at runtime and the field values
-         * from the derived object are copied to the base class object.
+         * A noop method.
          *
          * @param obj - the base object instance
          * @throws MetadataException
          */
         public synchronized Object get(Object obj) throws MetadataException
         {
-            if(obj == null) return null;
-            if(superRef.isJavaInheritance())
-            {
-                return obj;
-            }
-            else
+            //System.out.println("super.get: " + obj);
+            //System.out.println(ExceptionHelper.buildExceptionStack("super.get: " + superRef));
+            if(!superRef.isJavaInheritance())
             {
                 throw new MetadataException("Declared super class '" + superRef.getClassDescriptor()
                         + "'is not assignable from " + obj.getClass() + ". Reference: " + toString());
-                // return getObjectWithDeclaredSuperClass(obj);
-            }
-        }
-
-        void copyFields(final ClassDescriptor targetCld, final Object target, final ClassDescriptor sourceCld,
-                        final Object source)
-        {
-            if(log.isDebugEnabled())
-            {
-                String msg = ("Copy fields from " + SystemUtils.LINE_SEPARATOR
-                        + "source object '" + (source != null ? source.getClass().getName() : null) + "'" + SystemUtils.LINE_SEPARATOR
-                        + "using source fields declared in '" + sourceCld.getClassNameOfObject() + "'" + SystemUtils.LINE_SEPARATOR
-                        + "to target object '" + (target != null ? target.getClass().getName() : null) + "'" + SystemUtils.LINE_SEPARATOR
-                        + "using target fields declared in '" + targetCld.getClassNameOfObject() + "'" + SystemUtils.LINE_SEPARATOR
-                        + "the fields to copy are declared in '" + targetCld.getClassNameOfObject());
-                log.debug(msg);
-            }
-            /*
-            arminw:
-            If the target object is a super object of the source object, iterate all target object fields.
-            If java inheritance is used (target is super class of source or vice versa) we can use the same
-            FieldDescriptor to copy the fields.
-            */
-            FieldDescriptor[] fields = targetCld.getFieldDescriptions();
-            for(int i = 0; i < fields.length; i++)
-            {
-                FieldDescriptor field = fields[i];
-                if(!field.isAnonymous())
-                {
-                    performFieldCopy(target, source, field.getPersistentField());
-                }
             }
-            List refs = targetCld.getCollectionDescriptors();
-            for(int i = 0; i < refs.size(); i++)
-            {
-                CollectionDescriptor col = (CollectionDescriptor) refs.get(i);
-                PersistentField pf = col.getPersistentField();
-                performFieldCopy(target, source, pf);
-            }
-
-            refs = targetCld.getObjectReferenceDescriptors();
-            for(int i = 0; i < refs.size(); i++)
-            {
-                ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) refs.get(i);
-                PersistentField pf = ord.getPersistentField();
-                performFieldCopy(target, source, pf);
-            }
-        }
-
-        private void performFieldCopy(final Object target, final Object source, final PersistentField pf)
-        {
-            pf.set(target, pf.get(source));
+            return obj;
         }
-
-        public String toString()
-        {
-            return new ToStringBuilder(this)
-                    .append("name", getName())
-                    .append("type", getType())
-                    .append("super-reference", superRef)
-                    .toString();
-        }
-
-// arminw: the code below is a first attempt to support "table-per-subclass"-inheritance
-// for objects without java-subclass inheritance. But it's only possible for simple single-level
-// inheritance of "declared" objects
-//        void copyFields(final ClassDescriptor targetCld, final Object target, final ClassDescriptor sourceCld,
-//                        final Object source, final boolean targetIsSuper, final boolean javaInheritance)
-//        {
-//            if(log.isDebugEnabled())
-//            {
-//                String msg = ("Copy fields from " + SystemUtils.LINE_SEPARATOR
-//                        + "source object '" + (source != null ? source.getClass().getName() : null) + "'" + SystemUtils.LINE_SEPARATOR
-//                        + "using source fields declared in '" + sourceCld.getClassNameOfObject() + "'" + SystemUtils.LINE_SEPARATOR
-//                        + "to target object '" + (target != null ? target.getClass().getName() : null) + "'" + SystemUtils.LINE_SEPARATOR
-//                        + "using target fields declared in '" + targetCld.getClassNameOfObject() + "'" + SystemUtils.LINE_SEPARATOR
-//                        + "the fields to copy are declared in '" + (targetIsSuper ? targetCld.getClassNameOfObject() : sourceCld.getClassNameOfObject()) + "' class" + SystemUtils.LINE_SEPARATOR
-//                        + "the used classes are associated by java inheritance: " + javaInheritance + SystemUtils.LINE_SEPARATOR);
-//                log.debug(msg);
-//            }
-//            /*
-//            arminw:
-//            If the target object is a super object of the source object, iterate all target object fields.
-//            If the source object is a super object of the target object, iterate all source object fields
-//
-//            If java inheritance is used (target is super class of source or vice versa) we can use the same
-//            FieldDescriptor to copy the fields.
-//            If only a "declarative inheritance" is used (no class inheritance, only identical field names of the super class)
-//            we have to use the associated FieldDescriptor of target and source ClassDescriptor
-//            */
-//            FieldDescriptor[] fields = targetIsSuper ? targetCld.getFieldDescriptions() : sourceCld.getFieldDescriptions();
-//            for(int i = 0; i < fields.length; i++)
-//            {
-//                FieldDescriptor field = fields[i];
-//                if(!field.isAnonymous())
-//                {
-////                    performFieldCopy(target,  targetCld, source, sourceCld,
-////                                field.getPersistentField(), targetIsSuper, javaInheritance);
-//                    performFieldCopy(target, source, field.getPersistentField());
-//                }
-//            }
-//            List refs = targetIsSuper ? targetCld.getCollectionDescriptors() : sourceCld.getCollectionDescriptors();
-//            for(int i = 0; i < refs.size(); i++)
-//            {
-//                CollectionDescriptor col = (CollectionDescriptor) refs.get(i);
-//                PersistentField pf = col.getPersistentField();
-//                //performFieldCopy(target,  targetCld, source, sourceCld, pf, targetIsSuper, javaInheritance);
-//                performFieldCopy(target, source, pf);
-//            }
-//
-//            refs = targetIsSuper ? targetCld.getObjectReferenceDescriptors() : sourceCld.getObjectReferenceDescriptors();
-//            for(int i = 0; i < refs.size(); i++)
-//            {
-//                ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) refs.get(i);
-//                PersistentField pf = ord.getPersistentField();
-//                //performFieldCopy(target,  targetCld, source, sourceCld, pf, targetIsSuper, javaInheritance);
-//                performFieldCopy(target, source, pf);
-//            }
-//        }
-//
-//
-//        private void performFieldCopy(Object target, ClassDescriptor targetCld, Object source,
-//                                 ClassDescriptor sourceCld, PersistentField pf, boolean targetIsSuper, boolean javaInheritance)
-//        {
-//            if(javaInheritance)
-//            {
-//                pf.set(target, pf.get(source));
-//            }
-//            else
-//            {
-//                if(targetIsSuper)
-//                {
-//                    if(pf instanceof SuperReferenceField)
-//                    {
-//                        log.error("Declared inheritance doesn't support nested super references, target '"
-//                                + targetCld.getClassNameOfObject() + "' has super reference");
-//                    }
-//                    else
-//                    {
-//                        PersistentField tmp = superRef.getDeclaredInheritanceField(sourceCld.getClassOfObject(), pf.getName());
-//                        pf.set(target, tmp.get(source));
-//                    }
-//                }
-//                else
-//                {
-//                    PersistentField tmp = superRef.getDeclaredInheritanceField(targetCld.getClassOfObject(), pf.getName());
-//                    tmp.set(target, pf.get(source));
-//                }
-//            }
-//        }
-//
-//        private Object getObjectWithDeclaredSuperClass(Object obj)
-//        {
-//            Object value = getFromFieldCache(obj);
-//            if(value == null)
-//            {
-//                ClassDescriptor baseCld = null;
-//                try
-//                {
-//                    baseCld = superRef.getClassDescriptor().getSuperClassDescriptor();
-//                    value = ClassHelper.buildNewObjectInstance(baseCld);
-//                }
-//                catch(Exception e)
-//                {
-//                    throw new MetadataException("Can't create new base class object for '"
-//                            + (baseCld != null ? baseCld.getClassNameOfObject() : null) + "'", e);
-//                }
-//                copyFields(baseCld, value, superRef.getClassDescriptor(), obj, true, false);
-//                putToFieldCache(obj, value);
-//            }
-//            return value;
-//        }
     }
 }
 

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectImpl.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDirectImpl.java Tue Oct 31 09:21:32 2006
@@ -20,7 +20,6 @@
 
 import org.apache.ojb.broker.metadata.MetadataException;
 import org.apache.ojb.broker.util.ClassHelper;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 
 /**
  * This {@link org.apache.ojb.broker.metadata.fieldaccess.PersistentField} implementation
@@ -185,9 +184,9 @@
     {
         try
         {
-            return field.get(ProxyHelper.getRealObject(target));
+            //return field.get(ProxyHelper.getRealObject(target));
             // TODO: don't make costly proxy test on field level use
-            // return field.get(target);
+            return field.get(target);
         }
         catch (IllegalAccessException e)
         {
@@ -216,9 +215,9 @@
             // thanks to Tomasz Wysocki for this trick
             if ((value != null) || !field.getType().isPrimitive())
             {
-                field.set(ProxyHelper.getRealObject(target), value);
+                //field.set(ProxyHelper.getRealObject(target), value);
                 // TODO: don't make costly proxy test on field level use
-                // field.set(target, value);
+                field.set(target, value);
             }
         }
         catch (NullPointerException ignored)

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java Tue Oct 31 09:21:32 2006
@@ -40,7 +40,6 @@
 import org.apache.ojb.broker.core.PersistenceBrokerImpl;
 import org.apache.ojb.broker.core.ValueContainer;
 import org.apache.ojb.broker.core.proxy.IndirectionHandler;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.CollectionDescriptor;
 import org.apache.ojb.broker.metadata.FieldDescriptor;
@@ -68,7 +67,6 @@
  * Furthermore it was used to introduce new features related to {@link org.apache.ojb.broker.PersistenceBroker} - these
  * new features and services (if they stand the test of time) will be moved to separate services in future.
  *
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  * @version $Id$
  */
 public class BrokerHelper
@@ -144,7 +142,7 @@
     {
         ClassDescriptor result;
 
-        if(aCld.getClassOfObject() == ProxyHelper.getRealClass(anObj))
+        if(aCld.getClassOfObject() == m_broker.getProxyFactory().getRealClass(anObj))
         {
             result = aCld;
         }
@@ -168,7 +166,7 @@
      */
     public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) throws PersistenceBrokerException
     {
-        IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectOrProxy);
+        IndirectionHandler handler = m_broker.getProxyFactory().getIndirectionHandler(objectOrProxy);
 
         if(handler != null)
         {
@@ -189,7 +187,31 @@
      */
     public ValueContainer[] getFkTargetValuesForObject(ObjectReferenceDescriptor rds, Object objOrProxy, boolean convertToSql) throws PersistenceBrokerException
     {
-        Class refClass = m_broker.getProxyFactory().getRealClass(objOrProxy);
+        if(objOrProxy == null) throw new NullPointerException("Can't get FK target values from 'null' object");
+
+        Class refClass;
+        Object source = null;
+        IndirectionHandler handler = m_broker.getProxyFactory().getIndirectionHandler(objOrProxy);
+        if(handler != null)
+        {
+            if(handler.alreadyMaterialized())
+            {
+                source = handler.getRealSubject();
+                refClass = source.getClass();
+            }
+            else
+            {
+                refClass = handler.getIdentity().getObjectsRealClass();
+            }
+        }
+        else
+        {
+            source = objOrProxy;
+            // a object referenced by a super-reference-descriptor could never be a proxy object
+            // thus we only need to check this here
+            refClass = rds.isSuperReferenceDescriptor() ? rds.getItemClass() : objOrProxy.getClass();
+        }
+
         ClassDescriptor refCld = m_broker.getClassDescriptor(refClass);
         FieldDescriptor pkFd[] = refCld.getPkFields();
         FieldDescriptor targetFd[] = rds.getForeignKeyTargetFieldDescriptors(refCld);
@@ -197,7 +219,17 @@
         // use the values of the key-fields
         if (targetFd.length == 0 || Arrays.equals(pkFd, targetFd))
         {
-            return getKeyValues(refCld, objOrProxy, convertToSql);
+            /*
+            arminw:
+            when using a 'super-reference' (specific 1:1 reference to enable "table per subclass"-inheritance) it's
+            important to use the pk-fields of the referenced class and not the pk-fields of the specified object
+            because when using 'super-references' the same object instance is used for base object and referenced
+            object. But we want the PK's defined in the super class, because the PK field can be overriden in
+            the sub-class, thus we have to "upcast" to fields of the super-class.
+            */
+            return source != null ?
+                    getValuesForObject(pkFd, source, convertToSql)
+                    : getKeyValues(refCld, handler.getIdentity(), convertToSql);
         }
         
         // use the values of the target-fields
@@ -307,7 +339,7 @@
         FieldDescriptor[] fields = cld.getPkFields();
         boolean hasNull = false;
         // an unmaterialized proxy object can never have nullified PK's
-        IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
+        IndirectionHandler handler = m_broker.getProxyFactory().getIndirectionHandler(obj);
         if(handler == null || handler.alreadyMaterialized())
         {
             if(handler != null) obj = handler.getRealSubject();
@@ -493,7 +525,7 @@
      */
     public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj)
     {
-        if(!ProxyHelper.isProxy(obj))
+        if(!m_broker.getProxyFactory().isProxy(obj))
         {
             FieldDescriptor fieldDescriptors[] = cld.getPkFields();
             int fieldDescriptorSize = fieldDescriptors.length;
@@ -823,7 +855,8 @@
      */
     public boolean link(Object obj, String attributeName, Object reference, boolean insert)
     {
-        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
+        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(
+                m_broker.getProxyFactory().getRealClass(obj));
         ObjectReferenceDescriptor ord;
         boolean match = false;
         // first look for reference then for collection
@@ -884,7 +917,8 @@
     private boolean linkOrUnlink(boolean doLink, Object obj, String attributeName, boolean insert)
     {
         boolean match = false;
-        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
+        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(
+                m_broker.getProxyFactory().getRealClass(obj));
         ObjectReferenceDescriptor ord;
 
         // first look for reference then for collection
@@ -949,7 +983,7 @@
         ClassDescriptor cld = ord.getClassDescriptor();
         if(cld.isInterface())
         {
-            cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
+            cld = m_broker.getDescriptorRepository().getDescriptorFor(m_broker.getProxyFactory().getRealClass(obj));
         }
 
         if (doLink)

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java?view=diff&rev=469569&r1=469568&r2=469569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java Tue Oct 31 09:21:32 2006
@@ -17,16 +17,16 @@
 
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Collection;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
-import java.util.Vector;
 
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.accesslayer.StatementManagerIF;
+import org.apache.ojb.broker.platforms.Platform;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.metadata.DescriptorRepository;
 import org.apache.ojb.broker.metadata.FieldDescriptor;
 import org.apache.ojb.broker.metadata.SequenceDescriptor;
 import org.apache.ojb.broker.query.Query;
@@ -124,81 +124,76 @@
         if we found a sequence name bound to the field descriptor
         via 'sequence-name' attribute we use that name
         */
-        if(seqName != null && seqName.trim().length() != 0)
+        if(seqName == null || seqName.trim().length() == 0)
         {
-            return seqName;
-        }
-        else if(!autoNaming)
-        {
-            /*
-            arminw:
-            we don't find a sequence name and we should not automatic build one,
-            thus we throw an exception
-            */
-            throw new SequenceManagerException("Could not find sequence-name for field '" +
-                    field + "' of class '" + field.getClassDescriptor().getClassNameOfObject() +
-                    "', property 'seq.autoNaming' in sequence-manager element in repository was '" +
-                    autoNaming + "'. Set 'seq.autoNaming' true in sequence-descriptor or define a " +
-                    " sequence-name in field-descriptor.");
-        }
-
-        ClassDescriptor cldTargetClass = field.getClassDescriptor();
-        /*
-        check for inheritance on multiple table
-        */
-        cldTargetClass = findInheritanceRoot(cldTargetClass);
-        Class topLevel = brokerForClass.getTopLevelClass(cldTargetClass.getClassOfObject());
-        ClassDescriptor cldTopLevel = brokerForClass.getClassDescriptor(topLevel);
-        /**
-         *
-         * MBAIRD
-         * Should not use classname for the sequenceName as we will end up
-         * re-using sequence numbers for classes mapped to the same table.
-         * Instead, make the FullTableName the discriminator since it will
-         * always be unique for that table, and hence that class.
-         *
-         * arminw:
-         * If the found top-level class has extents, we take the first
-         * found extent class table name as sequence name. Else we take
-         * the table name of the 'targetClass'.
-         *
-         */
-        if(cldTopLevel.isExtent())
-        {
-            /*
-            arminw:
-            this is a little critical, because we do not know if the extent classes
-            will change by and by and the first found extent class may change, thus the
-            returned table name could change!
-            But I don't know a way to resolve this problem. I put a comment to the
-            sequence manager docs
-            TODO: find better solution
-            */
-//            seqName = brokerForClass.getClassDescriptor(((Class) cldTopLevel.getExtentClasses().
-//                    get(0))).getFullTableName();
-            seqName = firstFoundTableName(brokerForClass, cldTopLevel);
-        }
-        else
-        {
-            seqName = cldTargetClass.getFullTableName();
-        }
-//        log.info("* targetClass: "+targetClass +", toplevel: "+topLevel+ " seqName: "+seqName);
-        if(seqName == null)
-        {
-            seqName = SEQ_UNASSIGNED;
-            log.warn("Too complex structure, can not assign automatic sequence name for field '" +
-                    field.getAttributeName() + "' in class '" +
-                    field.getClassDescriptor().getClassNameOfObject() +
-                    "'. Use a default sequence name instead: " + (SEQ_PREFIX + seqName));
+            if(autoNaming)
+            {
+                /**
+                 * MBAIRD
+                 * Should not use classname for the sequence name as we will end up re-using sequence numbers for
+                 * classes mapped to the same table. Instead, make the FullTableName the discriminator since it will
+                 * always be unique for that table, and hence that class.
+                 *
+                 * arminw:
+                 * If the found top-level class has extents, we take the first found extent class table name as
+                 * sequence name. Else we take the table name of the 'targetClass'.
+                 */
+                ClassDescriptor cldTargetClass = field.getClassDescriptor();
+                DescriptorRepository model = cldTargetClass.getRepository();
+                /*
+                check for table-per-subclass inheritance
+                */
+                cldTargetClass = findInheritanceRoot(cldTargetClass);
+                Class topLevel = model.getTopLevelClass(cldTargetClass.getClassOfObject());
+                cldTargetClass = model.getDescriptorFor(topLevel);
+                if(cldTargetClass.isInterface() || cldTargetClass.isAbstract())
+                {
+                    /*
+                    arminw:
+                    this is a little critical, because we do not know if the extent classes
+                    will change by and by and the first found extent class may change, thus the
+                    returned table name could change!
+                    But I don't know a way to resolve this problem. I put a comment to the
+                    sequence manager docs
+                    TODO: find better solution
+                    */
+                    cldTargetClass = cldTargetClass.getRepository().findFirstConcreteClass(cldTargetClass);
+                }
+                seqName = cldTargetClass.getFullTableName();
+                //        log.info("* targetClass: "+targetClass +", toplevel: "+topLevel+ " seqName: "+seqName);
+                if(seqName == null)
+                {
+                    seqName = SEQ_UNASSIGNED;
+                    log.warn("Too complex structure, can not assign automatic sequence name for field '" +
+                            field.getAttributeName() + "' in class '" +
+                            field.getClassDescriptor().getClassNameOfObject() +
+                            "'. Use a default sequence name instead: " + (SEQ_PREFIX + seqName));
+                }
+                //        System.out.println("* targetClass: " + cldTargetClass.getClassNameOfObject() + ", toplevel: " + topLevel + " seqName: " + seqName);
+                seqName = SEQ_PREFIX + seqName;
+                if(log.isDebugEnabled())
+                {
+                    log.debug("Set automatic generated sequence-name for field '" +
+                            field.getAttributeName() + "' in class '" +
+                            field.getClassDescriptor().getClassNameOfObject() +
+                            "'.");
+                }
+                field.setSequenceName(seqName);
+            }
+            else
+            {
+                /*
+                arminw:
+                we don't find a sequence name and we can't automatic build one,
+                thus we throw an exception
+                */
+                throw new SequenceManagerException("Could not find sequence-name for field '" +
+                        field + "' of class '" + field.getClassDescriptor().getClassNameOfObject() +
+                        "', property 'seq.autoNaming' in sequence-manager element in repository was '" +
+                        autoNaming + "'. Set autoNaming 'true' in sequence-descriptor or define a " +
+                        " 'sequence-name' in field-descriptor.");
+            }
         }
-//        System.out.println("* targetClass: " + cldTargetClass.getClassNameOfObject() + ", toplevel: " + topLevel + " seqName: " + seqName);
-        seqName = SEQ_PREFIX + seqName;
-        if(log.isDebugEnabled())
-            log.debug("Set automatic generated sequence-name for field '" +
-                    field.getAttributeName() + "' in class '" +
-                    field.getClassDescriptor().getClassNameOfObject() +
-                    "'.");
-        field.setSequenceName(seqName);
         return seqName;
     }
 
@@ -218,31 +213,6 @@
     }
 
     /**
-     * try to find the first none null table name for the given class-descriptor.
-     * If cld has extent classes, all of these cld's searched for the first none null
-     * table name.
-     */
-    private static String firstFoundTableName(PersistenceBroker brokerForClass, ClassDescriptor cld)
-    {
-        String name = null;
-        if(!cld.isInterface() && cld.getFullTableName() != null)
-        {
-            return cld.getFullTableName();
-        }
-        if(cld.isExtent())
-        {
-            Collection extentClasses = cld.getExtentClasses();
-            for(Iterator iterator = extentClasses.iterator(); iterator.hasNext();)
-            {
-                name = firstFoundTableName(brokerForClass, brokerForClass.getClassDescriptor((Class) iterator.next()));
-                // System.out.println("## " + cld.getClassNameOfObject()+" - name: "+name);
-                if(name != null) break;
-            }
-        }
-        return name;
-    }
-
-    /**
      * Lookup all tables associated with given class (search all extent classes)
      * to find the current maximum value for the given field.
      * <br><b>Note:</b> Only works for <code>long</code> autoincrement fields.
@@ -286,7 +256,7 @@
         // if class is an extent we have to search through its subclasses
         if(cld.isExtent())
         {
-            Vector extentClasses = cld.getExtentClasses();
+            List extentClasses = cld.getExtentClasses();
             for(int i = 0; i < extentClasses.size(); i++)
             {
                 Class extentClass = (Class) extentClasses.get(i);
@@ -339,14 +309,14 @@
             return 0;
         }
 
-        String column = field.getColumnName();
+        Platform platform = brokerForClass.serviceConnectionManager().getSupportedPlatform();
+        StatementManagerIF sm = brokerForClass.serviceStatementManager();
+        String column = platform.quoteName(field.getColumnName());
+        String table = platform.quoteName(cldForOriginalOrExtent.getFullTableName());
+        String sql = SM_SELECT_MAX + column + SM_FROM + table;
         long result = 0;
         ResultSet rs = null;
         Statement stmt = null;
-        StatementManagerIF sm = brokerForClass.serviceStatementManager();
-        String table = cldForOriginalOrExtent.getFullTableName();
-        // String column = cld.getFieldDescriptorByName(fieldName).getColumnName();
-        String sql = SM_SELECT_MAX + column + SM_FROM + table;
         try
         {
             //lookup max id for the current class



---------------------------------------------------------------------
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