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
This commit is contained in:
Fay Wang 2010-06-02 15:42:20 +00:00
parent ebd07c943a
commit 65bf030d71
2 changed files with 11 additions and 3 deletions

View File

@ -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);
}

View File

@ -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())).