openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dez...@apache.org
Subject svn commit: r802208 - in /openjpa/branches/1.1.x/openjpa-jdbc/src: main/java/org/apache/openjpa/jdbc/meta/ main/java/org/apache/openjpa/jdbc/schema/ main/java/org/apache/openjpa/jdbc/sql/ test/java/org/apache/openjpa/jdbc/meta/
Date Fri, 07 Aug 2009 21:30:02 GMT
Author: dezzio
Date: Fri Aug  7 21:30:02 2009
New Revision: 802208

URL: http://svn.apache.org/viewvc?rev=802208&view=rev
Log:
OpenJPA-1051: merged fix from trunk rev 774580: "Mappingtool doesn't check name conflicts
if MappingDefaultsImpl is called with multiple columns"

Added:
    openjpa/branches/1.1.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/
      - copied from r774580, openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/
    openjpa/branches/1.1.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
      - copied unchanged from r774580, openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
Modified:
    openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
    openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
    openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java
    openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java
  (props changed)

Modified: openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java?rev=802208&r1=802207&r2=802208&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
(original)
+++ openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
Fri Aug  7 21:30:02 2009
@@ -539,7 +539,9 @@
             else if (_dsIdName != null)
                 cols[i].setName(_dsIdName + i);
             correctName(table, cols[i]);
+            table.addSubColumn(cols[i].getName());
         }
+        table.resetSubColumns();
     }
 
     /**
@@ -582,7 +584,9 @@
             } 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,
@@ -593,7 +597,9 @@
             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,
@@ -618,8 +624,11 @@
 
     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,
@@ -630,7 +639,9 @@
             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()));
     }
@@ -643,7 +654,9 @@
             else if (_nullIndName != null)
                 cols[i].setName(_nullIndName + i);
             correctName(table, cols[i]);
+            table.addSubColumn(cols[i].getName());
         }
+        table.resetSubColumns();
         return _addNullInd;
     }
 

Modified: openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java?rev=802208&r1=802207&r2=802208&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
(original)
+++ openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
Fri Aug  7 21:30:02 2009
@@ -39,13 +39,17 @@
 
     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());
+        return (_names != null && _names.contains(name.toUpperCase())) ||
+            (_subNames != null && _subNames.contains(name.toUpperCase()));
     }
 
     /**
@@ -77,4 +81,20 @@
         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;
+    }
 }

Modified: openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java?rev=802208&r1=802207&r2=802208&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java
(original)
+++ openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java
Fri Aug  7 21:30:02 2009
@@ -702,4 +702,15 @@
     public void setComment(String comment) {
         _comment = comment;
     }
+
+    /**
+    * Add a column to the subNames set to avoid naming conflict.
+    */
+    public void addSubColumn(String name) {
+        addSubName(name);
+    }
+
+    public void resetSubColumns() {
+        resetSubNames();
+    }
 }

Propchange: openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug  7 21:30:02 2009
@@ -1 +1 @@
-/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java:629627-711726
+/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java:629627-711726,774580



Mime
View raw message