From 45eb530812221b3e2b0a4d095a703ea4b95a6f2a Mon Sep 17 00:00:00 2001 From: Michael Dick Date: Wed, 12 Dec 2007 14:59:12 +0000 Subject: [PATCH] OPENJPA-456 committing patch provided by Teresa Kan git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@603633 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/jdbc/PersistenceMappingDefaults.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java index 94e33a730..fa31b79e3 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java @@ -157,9 +157,15 @@ public class PersistenceMappingDefaults name = inverses[0].getName(); else name = fm.getDefiningMapping().getTypeAlias(); - + String targetName = ((Column) target).getName(); + String tempName = null; + if ((name.length() + targetName.length()) >= dict.maxColumnNameLength) + tempName = name.substring(0, dict.maxColumnNameLength + - targetName.length() - 1); // suffix with '_' + target column - name += "_" + ((Column) target).getName(); + if (tempName == null) + tempName = name; + name = tempName + "_" + targetName; name = dict.getValidColumnName(name, foreign); col.setName(name); }