OPENJPA-399 committing Teresa's patch

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.0.x@589784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2007-10-29 18:21:56 +00:00
parent 446a0e0543
commit 3860784216
3 changed files with 33 additions and 7 deletions

View File

@ -235,16 +235,15 @@ public class TableJDBCSeq
schema = group.addSchema(schemaName);
schema.importTable(_pkColumn.getTable());
// build the index for the sequence tables
// the index name will the fully qualified table name +_IDX
Table tab = schema.getTable(_table);
Index idx = tab.addIndex(tab.getFullName()+"_IDX");
idx.setUnique(true);
// we need to reset the table name in the column with the
// fully qualified name for matching the table name from the
// Column.
_pkColumn.resetTableName(schemaName+"."+_pkColumn.getTableName());
idx.addColumn(_pkColumn);
_pkColumn.resetTableName(schemaName + "."
+ _pkColumn.getTableName());
// some databases require to create an index for the sequence table
_conf.getDBDictionaryInstance().createIndexIfNecessary(schema,
_table, _pkColumn);
}
}

View File

@ -31,12 +31,17 @@ import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
import org.apache.openjpa.jdbc.kernel.exps.Lit;
import org.apache.openjpa.jdbc.kernel.exps.Param;
import org.apache.openjpa.jdbc.kernel.exps.Val;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.Schema;
import org.apache.openjpa.jdbc.schema.Sequence;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.kernel.Filters;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.util.OpenJPAException;
import org.apache.openjpa.util.UnsupportedException;
import serp.util.Strings;
/**
@ -742,4 +747,19 @@ public class DB2Dictionary
}
}
}
/**
* Create an index if necessary for some database tables
*/
public void createIndexIfNecessary(Schema schema, String table,
Column pkColumn) {
if (isDB2ZOSV8xOrLater()) {
// build the index for the sequence tables
// the index name will the fully qualified table name + _IDX
Table tab = schema.getTable(table);
Index idx = tab.addIndex(tab.getFullName() + "_IDX");
idx.setUnique(true);
idx.addColumn(pkColumn);
}
}
}

View File

@ -3982,4 +3982,11 @@ public class DBDictionary
public String getCastFunction(Val val, String func) {
return func;
}
/**
* Create an index if necessary for some database tables
*/
public void createIndexIfNecessary(Schema schema, String table,
Column pkColumn) {
}
}