db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r465604 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
Date Thu, 19 Oct 2006 12:29:21 GMT
Author: arminw
Date: Thu Oct 19 05:29:20 2006
New Revision: 465604

URL: http://svn.apache.org/viewvc?view=rev&rev=465604
Log:
minor improvement handling autoIncrement fields

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java

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=465604&r1=465603&r2=465604
==============================================================================
--- 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
Thu Oct 19 05:29:20 2006
@@ -216,6 +216,7 @@
     //-----------------------------------------------------------------
     //-----------------------------------------------------------------
     private FieldDescriptor m_autoIncrementField = null;
+    private FieldDescriptor[] autoIncrementFields = null;
     /**
      * the FieldDescriptors for the primitive attributes
      */
@@ -430,13 +431,7 @@
             Arrays.sort(m_FieldDescriptions, FieldDescriptor.getComparator());
         }
 
-        m_fieldDescriptorNameMap = null;
-        m_PkFieldDescriptors = null;
-        m_nonPkFieldDescriptors = null;
-        m_lockingFieldDescriptors = null;
-        m_RwFieldDescriptors = null;
-        m_RwNonPkFieldDescriptors = null;
-        lobFields = null;
+        resetConvenienceFields();
     }
 
     public boolean removeFieldDescriptor(FieldDescriptor fld)
@@ -448,6 +443,13 @@
         result = list.remove(fld);
         m_FieldDescriptions = (FieldDescriptor[]) list.toArray(new FieldDescriptor[list.size()]);
 
+        resetConvenienceFields();
+
+        return result;
+    }
+
+    protected void resetConvenienceFields()
+    {
         m_fieldDescriptorNameMap = null;
         m_PkFieldDescriptors = null;
         m_nonPkFieldDescriptors = null;
@@ -455,7 +457,8 @@
         m_RwFieldDescriptors = null;
         m_RwNonPkFieldDescriptors = null;
         lobFields = null;
-        return result;
+        m_autoIncrementField = null;
+        autoIncrementFields = null;
     }
 
     /**
@@ -938,15 +941,23 @@
         return m_autoIncrementField;
     }
 
+    /**
+     * Returns all fields declared as 'autoIncrement' fields.
+     */
     public FieldDescriptor[] getAutoIncrementFields()
     {
-        ArrayList result = new ArrayList();
-        for (int i = 0; i < m_FieldDescriptions.length; i++)
+        if(autoIncrementFields == null)
         {
-            FieldDescriptor field = m_FieldDescriptions[i];
-            if(field.isAutoIncrement()) result.add(field);
+            ArrayList result = new ArrayList();
+            FieldDescriptor[] fields = getFieldDescriptor(false);
+            for (int i = 0; i < fields.length; i++)
+            {
+                FieldDescriptor field = fields[i];
+                if(field.isAutoIncrement()) result.add(field);
+            }
+            autoIncrementFields = (FieldDescriptor[]) result.toArray(new FieldDescriptor[result.size()]);
         }
-        return (FieldDescriptor[]) result.toArray(new FieldDescriptor[result.size()]);
+        return autoIncrementFields;
     }
 
     /**



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