From 65bf030d714675f3ce30e1f428ad5807543a6dd4 Mon Sep 17 00:00:00 2001 From: Fay Wang Date: Wed, 2 Jun 2010 15:42:20 +0000 Subject: [PATCH] OPENJPA-1596: port the change to 2.0 git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@950604 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java | 7 +++++-- .../java/org/apache/openjpa/jdbc/sql/DBDictionary.java | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java index 042344434..97906cea5 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java @@ -33,6 +33,7 @@ import java.util.Set; import java.util.StringTokenizer; import org.apache.openjpa.jdbc.identifier.DBIdentifier; +import org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier; import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; import org.apache.openjpa.jdbc.kernel.exps.Lit; @@ -912,8 +913,10 @@ public class DB2Dictionary // build the index for the sequence tables // the index name will be the fully qualified table name + _IDX Table tab = schema.getTable(table); - DBIdentifier idxName = DBIdentifier.append(tab.getFullIdentifier(), "IDX"); - Index idx = tab.addIndex(getValidIndexName(idxName, tab)); + DBIdentifier fullIdxId = tab.getFullIdentifier().clone(); + DBIdentifier unQualifiedName = DBIdentifier.append(fullIdxId.getUnqualifiedName(), "IDX"); + fullIdxId.setName(getValidIndexName(unQualifiedName, tab)); + Index idx = tab.addIndex(fullIdxId); idx.setUnique(true); idx.addColumn(pkColumn); } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index d4303b377..1bea4cd4c 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -3408,8 +3408,13 @@ public class DBDictionary buf.append("CREATE "); if (index.isUnique()) buf.append("UNIQUE "); - String indexName = checkNameLength(toDBName(index.getIdentifier()), maxIndexNameLength, + + DBIdentifier fullIdxName = index.getIdentifier(); + DBIdentifier unQualifiedName = fullIdxName.getUnqualifiedName(); + checkNameLength(toDBName(unQualifiedName), maxIndexNameLength, "long-index-name"); + String indexName = toDBName(fullIdxName); + buf.append("INDEX ").append(indexName); buf.append(" ON ").append(getFullName(index.getTable(), false)); buf.append(" (").append(namingUtil.appendColumns(index.getColumns())).