From fd07caa0a0c2032f059dcedb369c93df83de2618 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 25 Apr 2007 22:39:34 +0000 Subject: [PATCH] Fix [ 1705182 ] ORA-00972: identifier is too long avoid IndexOutOfBoundsException - thanks Tim for reporting --- dbPort/src/org/compiere/model/MColumn.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dbPort/src/org/compiere/model/MColumn.java b/dbPort/src/org/compiere/model/MColumn.java index ab6afc8f36..d3423f1e92 100644 --- a/dbPort/src/org/compiere/model/MColumn.java +++ b/dbPort/src/org/compiere/model/MColumn.java @@ -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)