mirror of https://github.com/apache/openjpa.git
OPENJPA-605 Informix will throw an exception when a unique index is explictily created on the primary key columns
Help committing new patch provided by Fay Wang git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@658576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
689eec175b
commit
b2bd03567d
|
@ -988,20 +988,9 @@ public class SchemaTool {
|
|||
throws SQLException {
|
||||
// Informix will automatically create a unique index for the
|
||||
// primary key, so don't create another index again
|
||||
if (_dict.platform.indexOf("Informix") > -1) {
|
||||
Column[] cols = idx.getColumns();
|
||||
Column[] pkCols = table.getPrimaryKey().getColumns();
|
||||
if (cols.length == pkCols.length) {
|
||||
String[] colNames = new String[cols.length];
|
||||
String[] pkColNames = new String[cols.length];
|
||||
for (int i = 0; i < cols.length; i++)
|
||||
colNames[i] = cols[i].getName();
|
||||
for (int i = 0; i < pkCols.length; i++)
|
||||
pkColNames[i] = pkCols[i].getName();
|
||||
if (java.util.Arrays.equals(colNames, pkColNames))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_dict.needsToCreateIndex(idx,table))
|
||||
return false;
|
||||
|
||||
int max = _dict.maxIndexesPerTable;
|
||||
|
||||
|
|
|
@ -4407,4 +4407,8 @@ public class DBDictionary
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean needsToCreateIndex(Index idx, Table table) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,4 +268,13 @@ public class InformixDictionary
|
|||
FilterValue start) {
|
||||
throw new UnsupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean needsToCreateIndex(Index idx, Table table) {
|
||||
// Informix will automatically create a unique index for the
|
||||
// primary key, so don't create another index again
|
||||
PrimaryKey pk = table.getPrimaryKey();
|
||||
if (pk != null && idx.columnsMatch(pk.getColumns()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue