From ee33aa7af3ed765aee95e38773b042c1e5194fbe Mon Sep 17 00:00:00 2001 From: "A. Abram White" Date: Tue, 5 Dec 2006 20:49:11 +0000 Subject: [PATCH] Default name fix. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@482775 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/jdbc/PersistenceMappingDefaults.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 1a593d325..ded3d6f74 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 @@ -160,18 +160,22 @@ public class PersistenceMappingDefaults public void populateForeignKeyColumn(ValueMapping vm, String name, Table local, Table foreign, Column col, Object target, boolean inverse, int pos, int cols) { + boolean elem = vm == vm.getFieldMapping().getElement() + && vm.getFieldMapping().getTypeCode() != JavaTypes.MAP; + // if this is a non-inverse collection element key, it must be in // a join table: if we're not prepending the field name, leave the // default - if (!_prependFieldNameToJoinTableInverseJoinColumns && !inverse - && vm == vm.getFieldMapping().getElement() - && vm.getFieldMapping().getTypeCode() != JavaTypes.MAP) + if (!_prependFieldNameToJoinTableInverseJoinColumns && !inverse && elem) return; // otherwise jpa always uses _ for column name, even // when only one col - if (target instanceof Column) + if (target instanceof Column) { + if (elem) + name = vm.getFieldMapping().getName(); col.setName(name + "_" + ((Column) target).getName()); + } } @Override