Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorkmoore2009-04-17 18:03:42 +0000
committerkmoore2009-04-17 18:03:42 +0000
commit92f0e5c8bc89722961261c3c17237173769859f2 (patch)
tree63955ad47efaad3a722991bf8ccb4ca242a62f5b /jpa
parentefdb5990fbe9478740f476421611ec12eab80ae8 (diff)
downloadwebtools.dali-92f0e5c8bc89722961261c3c17237173769859f2.tar.gz
webtools.dali-92f0e5c8bc89722961261c3c17237173769859f2.tar.xz
webtools.dali-92f0e5c8bc89722961261c3c17237173769859f2.zip
272696 - patch from Danny Ju - relationship mappings generated incorrectly after fix to bug 270966
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java24
2 files changed, 22 insertions, 7 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
index 20d1ed3239..e891f28ca0 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
@@ -357,6 +357,11 @@ public class ORMGenColumn
setCustomizedBoolean(GENERATED, value, true);
}
+ @Override
+ public String toString() {
+ return "name=" + getName() + "; type=" + getPropertyType() ; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
/*get/set and field scopes*/
public static final String PUBLIC_SCOPE = "public"; //$NON-NLS-1$
public static final String PROTECTED_SCOPE = "protected"; //$NON-NLS-1$
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 b11f814475..9d510a5df9 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
@@ -697,9 +697,14 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
mAssociations.addAll(addedAssociations);
}
private Association computeManyToMany(ORMGenTable table, List<Association> addedAssociations) {
- /*many-to-many associations if:
- * -addedAssociations contains 2 many-to-one associations to 2 different tables t1 and t2.
- * -<code>table</code> contains only the primary key columns.
+ /** many-to-many associations if:
+ * - addedAssociations contains 2 many-to-one associations
+ * - tables t1 and t2 does NOT have to be different( for self-MTM-self situation)
+ * - <code>table</code> contains only the foreign key columns.
+ *
+ * Note: following restrictions have been removed:
+ * -table has only two columns
+ * -t1 and t2 must be different
* -the primary key of <code>table</code> is the concatenation of its foreign
* keys to t1 and t2.*/
@@ -707,19 +712,24 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
return null;
}
+ //MTM table should have two MTO relations to orginal tables
Association assoc1 = addedAssociations.get(0);
Association assoc2 = addedAssociations.get(1);
if (assoc1.getCardinality() != Association.MANY_TO_ONE
|| assoc2.getCardinality() != Association.MANY_TO_ONE) {
return null;
}
+
+ //MTM table should only include foreign key columns
+ for( ORMGenColumn col : table.getColumns()){
+ if( !col.isForeignKey())
+ return null;
+ }
+
+
ORMGenTable t1 = assoc1.getReferencedTable();
ORMGenTable t2 = assoc2.getReferencedTable();
-//Commented out because the assumption is too restrictive:
-//this check will prevent generating table MTM to itself
-// if (t1.getName().equals(t2.getName()) ||
-// t1.getName().equals(table.getName()) || t2.getName().equals(table.getName())) {
if( t1.getName().equals(table.getName()) || t2.getName().equals(table.getName()) ) {
return null;
}

Back to the top