Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-04-15 12:54:44 +0000
committerkmoore2009-04-15 12:54:44 +0000
commit891597248d7dff361418d4b996cf06d6e29086c1 (patch)
tree49c4a6c43cfdb7f98748d89e76831f42c8a6cee8
parent6f901133c1ff84617aaf429e026eae69aa09c960 (diff)
downloadwebtools.dali-891597248d7dff361418d4b996cf06d6e29086c1.tar.gz
webtools.dali-891597248d7dff361418d4b996cf06d6e29086c1.tar.xz
webtools.dali-891597248d7dff361418d4b996cf06d6e29086c1.zip
268445 - patch from Danny - Entity Generation - m-m with JoinTable could guess the owner better
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
index 9013983049..798f011206 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.db.Column;
+import org.eclipse.jpt.db.ForeignKey;
import org.eclipse.jpt.db.Schema;
import org.eclipse.jpt.db.Table;
import org.eclipse.jpt.gen.internal2.util.DTPUtil;
@@ -733,6 +734,20 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
if( t1.getName().equals(table.getName()) || t2.getName().equals(table.getName()) ) {
return null;
}
+
+ //Make a guess which table is the owning side of the MTM relation
+ //See https://bugs.eclipse.org/bugs/show_bug.cgi?id=268445
+ //Logic borrowed from DTPTableWrapper.getJoinTableOwningForeignKey()
+ if( !table.getName().equals(t1.getName() + "_" + t2.getName() ) ) {
+ //swap t1 and t2
+ ORMGenTable t3 = t1;
+ t1=t2;
+ t2=t3;
+ //swap assoc1 and assoc2
+ Association assoc3=assoc1;
+ assoc1=assoc2;
+ assoc2=assoc3;
+ }
//Commented out because the assumption is too restrictive:
//this check will prevent generating MTM mapping table not having

Back to the top