From 44ffbd2f792b9fb9cd423b40b7c0b2b50baf629d Mon Sep 17 00:00:00 2001 From: Fay Wang Date: Sun, 15 Mar 2009 22:04:03 +0000 Subject: [PATCH] OPENJPA-967: remove duplicate column in the associate table when MapKey is specified. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@754773 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/jdbc/meta/FieldMapping.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java index 636a69b4f..65a238995 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java @@ -25,7 +25,6 @@ import org.apache.openjpa.enhance.PersistenceCapable; import org.apache.openjpa.enhance.Reflection; import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; import org.apache.openjpa.jdbc.kernel.JDBCStore; -import org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.NoneFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.PrimitiveFieldStrategy; import org.apache.openjpa.jdbc.schema.Column; @@ -53,7 +52,6 @@ import org.apache.openjpa.util.ApplicationIds; import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.MetaDataException; import org.apache.openjpa.util.ObjectId; -import org.apache.openjpa.util.OpenJPAId; /** * Specialization of metadata for relational databases. @@ -160,6 +158,14 @@ public class FieldMapping if (meta != null) return meta.getTable(); } + + ValueMappingImpl vm = (ValueMappingImpl)getDefiningMapping(). + getEmbeddingMetaData(); + if (vm != null && vm.getValueMappedBy() != null) { + return vm.getFieldMapping().getElementMapping(). + getDeclaredTypeMapping().getTable(); + } + return getDefiningMapping().getTable(); }