openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r880821 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: meta/MappingDefaultsImpl.java schema/NameSet.java
Date Mon, 16 Nov 2009 15:58:24 GMT
Author: ppoddar
Date: Mon Nov 16 15:58:24 2009
New Revision: 880821

URL: http://svn.apache.org/viewvc?rev=880821&view=rev
Log:
OPENJPA-1051: Simplify check for uniqueness of column names. Patch contributed by Ravi Palacherla.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java?rev=880821&r1=880820&r2=880821&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
Mon Nov 16 15:58:24 2009
@@ -539,9 +539,7 @@
             else if (_dsIdName != null)
                 cols[i].setName(_dsIdName + i);
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
         }
-        table.resetSubColumns();
     }
 
     /**
@@ -553,7 +551,9 @@
             String name = col.getName();
             if (_removeHungarianNotation)
                 name = removeHungarianNotation(name);
-            col.setName(dict.getValidColumnName(name, table));
+            String correctedName = dict.getValidColumnName(name, table);
+            col.setName(correctedName);
+            table.addCorrectedColumnName(correctedName, true);
         }
     }
 
@@ -584,9 +584,7 @@
             } else if (_versName != null)
                 cols[i].setName(_versName + i);
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
         }
-        table.resetSubColumns();
     }
 
     public void populateColumns(Discriminator disc, Table table,
@@ -597,9 +595,7 @@
             else if (_discName != null)
                 cols[i].setName(_discName + i);
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
         }
-        table.resetSubColumns();
     }
 
     public void populateJoinColumn(ClassMapping cm, Table local, Table foreign,
@@ -624,11 +620,8 @@
 
     public void populateColumns(ValueMapping vm, String name, Table table,
         Column[] cols) {
-        for (int i = 0; i < cols.length; i++) {
+        for (int i = 0; i < cols.length; i++)
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
-        }
-        table.resetSubColumns();
     }
 
     public boolean populateOrderColumns(FieldMapping fm, Table table,
@@ -639,9 +632,7 @@
             else if (_orderName != null)
                 cols[i].setName(_orderName + i);
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
         }
-        table.resetSubColumns();
         return _orderLists && (JavaTypes.ARRAY == fm.getTypeCode()
             || List.class.isAssignableFrom(fm.getType()));
     }
@@ -654,9 +645,7 @@
             else if (_nullIndName != null)
                 cols[i].setName(_nullIndName + i);
             correctName(table, cols[i]);
-            table.addSubColumn(cols[i].getName());
         }
-        table.resetSubColumns();
         return _addNullInd;
     }
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java?rev=880821&r1=880820&r2=880821&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java Mon
Nov 16 15:58:24 2009
@@ -39,17 +39,13 @@
 
     private Set _names = null;
 
-    // an additional names Set for checking name duplication
-    private Set _subNames = null;
-
     /**
      * Return true if the given name is in use already.
      */
     public boolean isNameTaken(String name) {
         if (name == null)
             return true;
-        return (_names != null && _names.contains(name.toUpperCase())) ||
-            (_subNames != null && _subNames.contains(name.toUpperCase()));
+        return _names != null && _names.contains(name.toUpperCase());
     }
 
     /**
@@ -81,20 +77,4 @@
         if (name != null && _names != null)
             _names.remove(name.toUpperCase());
     }
-
-    /**
-    * Attempt to add the given name to the set.
-    *
-    * @param name the name to add
-    */
-    protected void addSubName(String name) {
-        if (_subNames == null) {
-            _subNames = new HashSet();
-        }
-        _subNames.add(name.toUpperCase());
-    }
-
-    protected void resetSubNames() {
-        _subNames = null;
-    }
 }



Mime
View raw message