Fix [ 1705182 ] ORA-00972: identifier is too long

avoid IndexOutOfBoundsException - thanks Tim for reporting
This commit is contained in:
Carlos Ruiz 2007-04-25 22:39:34 +00:00
parent 01ebaba0aa
commit fd07caa0a0
1 changed files with 9 additions and 2 deletions

View File

@ -427,8 +427,15 @@ public class MColumn extends X_AD_Column
*/
public String getConstraint(String tableName)
{
if (isKey())
return "CONSTRAINT " + tableName.substring(0, 26) + "_Key PRIMARY KEY (" + getColumnName() + ")";
if (isKey()) {
String constraintName;
if (tableName.length() > 26)
// Oracle restricts object names to 30 characters
constraintName = tableName.substring(0, 26) + "_Key";
else
constraintName = tableName + "_Key";
return "CONSTRAINT " + constraintName + " PRIMARY KEY (" + getColumnName() + ")";
}
/**
if (getAD_Reference_ID() == DisplayType.TableDir
|| getAD_Reference_ID() == DisplayType.Search)