You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2014/11/10 18:12:25 UTC

[5/8] cayenne git commit: Refactor Relationships Project

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK1.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK1.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK1.java
new file mode 100644
index 0000000..32dfca7
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK1.java
@@ -0,0 +1,27 @@
+package org.apache.cayenne.testdo.relationships_to_one_fk.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.testdo.relationships_to_one_fk.ToOneFK2;
+
+/**
+ * Class _ToOneFK1 was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _ToOneFK1 extends CayenneDataObject {
+
+    public static final String TO_PK_PROPERTY = "toPK";
+
+    public static final String TO_ONEFK1_PK_PK_COLUMN = "TO_ONEFK1_PK";
+
+    public void setToPK(ToOneFK2 toPK) {
+        setToOneTarget(TO_PK_PROPERTY, toPK, true);
+    }
+
+    public ToOneFK2 getToPK() {
+        return (ToOneFK2)readProperty(TO_PK_PROPERTY);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK2.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK2.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK2.java
new file mode 100644
index 0000000..15fcfdd
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_to_one_fk/auto/_ToOneFK2.java
@@ -0,0 +1,27 @@
+package org.apache.cayenne.testdo.relationships_to_one_fk.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.testdo.relationships_to_one_fk.ToOneFK1;
+
+/**
+ * Class _ToOneFK2 was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _ToOneFK2 extends CayenneDataObject {
+
+    public static final String TO_ONE_TO_FK_PROPERTY = "toOneToFK";
+
+    public static final String TO_ONEFK2_PK_PK_COLUMN = "TO_ONEFK2_PK";
+
+    public void setToOneToFK(ToOneFK1 toOneToFK) {
+        setToOneTarget(TO_ONE_TO_FK_PROPERTY, toOneToFK, true);
+    }
+
+    public ToOneFK1 getToOneToFK() {
+        return (ToOneFK1)readProperty(TO_ONE_TO_FK_PROPERTY);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
index 4677151..481b252 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
@@ -69,8 +69,10 @@ public class SchemaBuilder {
     public static final String SKIP_SCHEMA_KEY = "cayenne.test.schema.skip";
 
     private static String[] MAPS_REQUIRING_SCHEMA_SETUP = { "tstmap.map.xml", "people.map.xml", "inheritance.map.xml",
-            "locking.map.xml", "soft-delete.map.xml", "relationships.map.xml", "relationships1.map.xml", "multi-tier.map.xml",
-            "persistent.map.xml", "reflexive.map.xml", "delete-rules.map.xml", "lifecycles.map.xml",
+            "locking.map.xml", "soft-delete.map.xml", "relationships.map.xml", "relationships-activity.map.xml", "relationships-delete-rules.map.xml",
+            "relationships-collection-to-many.map.xml", "relationships-child-master.map.xml", "relationships-clob.map.xml",
+            "relationships-flattened.map.xml", "relationships-set-to-many.map.xml", "relationships-to-many-fk.map.xml", "relationships-to-one-fk.map.xml",
+            "multi-tier.map.xml", "persistent.map.xml", "reflexive.map.xml", "delete-rules.map.xml", "lifecycles.map.xml",
             "map-to-many.map.xml", "toone.map.xml", "meaningful-pk.map.xml", "table-primitives.map.xml",
             "generic.map.xml", "map-db1.map.xml", "map-db2.map.xml", "embeddable.map.xml", "qualified.map.xml",
             "quoted-identifiers.map.xml", "inheritance-single-table1.map.xml", "inheritance-vertical.map.xml",

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
index 4cd2e2e..b605e50 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
@@ -38,6 +38,15 @@ public class ServerCase extends DICase {
 	public static final String QUOTED_IDENTIFIERS_PROJECT = "cayenne-quoted-identifiers.xml";
 	public static final String PEOPLE_PROJECT = "cayenne-people.xml";
 	public static final String RELATIONSHIPS_PROJECT = "cayenne-relationships.xml";
+	public static final String RELATIONSHIPS_ACTIVITY_PROJECT = "cayenne-relationships-activity.xml";
+	public static final String RELATIONSHIPS_DELETE_RULES_PROJECT = "cayenne-relationships-delete-rules.xml";
+	public static final String RELATIONSHIPS_COLLECTION_TO_MANY_PROJECT = "cayenne-relationships-collection-to-many.xml";
+	public static final String RELATIONSHIPS_CHILD_MASTER_PROJECT = "cayenne-relationships-child-master.xml";
+	public static final String RELATIONSHIPS_CLOB_PROJECT = "cayenne-relationships-clob.xml";
+	public static final String RELATIONSHIPS_FLATTENED_PROJECT = "cayenne-relationships-flattened.xml";
+	public static final String RELATIONSHIPS_SET_TO_MANY_PROJECT = "cayenne-relationships-set-to-many.xml";
+	public static final String RELATIONSHIPS_TO_MANY_FK_PROJECT = "cayenne-relationships-to-many-fk.xml";
+	public static final String RELATIONSHIPS_TO_ONE_FK_PROJECT = "cayenne-relationships-to-one-fk.xml";
 	public static final String TESTMAP_PROJECT = "cayenne-testmap.xml";
 	public static final String DEFAULT_PROJECT = "cayenne-default.xml";
 	public static final String MULTINODE_PROJECT = "cayenne-multinode.xml";

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
index 03f695f..f4d8b3f 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
@@ -26,7 +26,7 @@ import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.relationship.ClobMaster;
+import org.apache.cayenne.testdo.relationships_clob.ClobMaster;
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertEquals;
 
 /**
  */
-@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+@UseServerRuntime(ServerCase.RELATIONSHIPS_CLOB_PROJECT)
 public class CAY_115IT extends ServerCase {
 
     @Inject

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
index 1c51d15..30d7d40 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
@@ -24,7 +24,7 @@ import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.relationship.FkOfDifferentType;
+import org.apache.cayenne.testdo.relationships.FkOfDifferentType;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
index caa711d..2fca6b9 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
@@ -26,7 +26,7 @@ import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.relationship.ReflexiveAndToOne;
+import org.apache.cayenne.testdo.relationships.ReflexiveAndToOne;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Test;
@@ -59,7 +59,6 @@ public class CAY_194IT extends ServerCase {
         tReflexive.update().set("PARENT_ID", null, Types.INTEGER).execute();
 
         dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
-        dbHelper.deleteAll("TO_ONEFK1");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-activity.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-activity.xml b/cayenne-server/src/test/resources/cayenne-relationships-activity.xml
new file mode 100644
index 0000000..d796cfe
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-activity.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-activity"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-child-master.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-child-master.xml b/cayenne-server/src/test/resources/cayenne-relationships-child-master.xml
new file mode 100644
index 0000000..bda49f7
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-child-master.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-child-master"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-clob.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-clob.xml b/cayenne-server/src/test/resources/cayenne-relationships-clob.xml
new file mode 100644
index 0000000..a28c631
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-clob.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-clob"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-collection-to-many.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-collection-to-many.xml b/cayenne-server/src/test/resources/cayenne-relationships-collection-to-many.xml
new file mode 100644
index 0000000..c8ca293
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-collection-to-many.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-collection-to-many"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-delete-rules.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-delete-rules.xml b/cayenne-server/src/test/resources/cayenne-relationships-delete-rules.xml
new file mode 100644
index 0000000..7f170a6
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-delete-rules.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-delete-rules"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-flattened.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-flattened.xml b/cayenne-server/src/test/resources/cayenne-relationships-flattened.xml
new file mode 100644
index 0000000..9452a56
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-flattened.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-flattened"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-set-to-many.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-set-to-many.xml b/cayenne-server/src/test/resources/cayenne-relationships-set-to-many.xml
new file mode 100644
index 0000000..10881da
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-set-to-many.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-set-to-many"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-to-many-fk.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-to-many-fk.xml b/cayenne-server/src/test/resources/cayenne-relationships-to-many-fk.xml
new file mode 100644
index 0000000..94792c3
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-to-many-fk.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-to-many-fk"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships-to-one-fk.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships-to-one-fk.xml b/cayenne-server/src/test/resources/cayenne-relationships-to-one-fk.xml
new file mode 100644
index 0000000..46da7b9
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-relationships-to-one-fk.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+    <map name="relationships-to-one-fk"/>
+</domain>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/cayenne-relationships.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-relationships.xml b/cayenne-server/src/test/resources/cayenne-relationships.xml
index 4b4752b..b7750ef 100644
--- a/cayenne-server/src/test/resources/cayenne-relationships.xml
+++ b/cayenne-server/src/test/resources/cayenne-relationships.xml
@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <domain project-version="7">
 	<map name="relationships"/>
-	<map name="relationships1"/>
 </domain>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-activity.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-activity.map.xml b/cayenne-server/src/test/resources/relationships-activity.map.xml
new file mode 100644
index 0000000..c85bc99
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-activity.map.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+	 project-version="7">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_activity"/>
+	<db-entity name="ACTIVITY">
+		<db-attribute name="ACTIVITY_ID" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
+		<db-attribute name="APPOINT_DATE" type="DATE" isMandatory="true"/>
+		<db-attribute name="APPOINT_NO" type="INTEGER" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="RESULT">
+		<db-attribute name="APPOINT_DATE" type="DATE" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="APPOINT_NO" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="RESULTNAME" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
+	</db-entity>
+	<obj-entity name="Activity" className="org.apache.cayenne.testdo.relationships_activity.Activity" dbEntityName="ACTIVITY">
+		<obj-attribute name="appointmentDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
+		<obj-attribute name="appointmentNo" type="int" db-attribute-path="APPOINT_NO"/>
+	</obj-entity>
+	<obj-entity name="ActivityResult" className="org.apache.cayenne.testdo.relationships_activity.ActivityResult" dbEntityName="RESULT">
+		<obj-attribute name="appointDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
+		<obj-attribute name="appointNo" type="int" db-attribute-path="APPOINT_NO"/>
+		<obj-attribute name="field" type="java.lang.String" db-attribute-path="RESULTNAME"/>
+	</obj-entity>
+	<db-relationship name="ActivityResultsRel" source="ACTIVITY" target="RESULT" toMany="true">
+		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
+		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
+	</db-relationship>
+	<db-relationship name="ActivitiesRel" source="RESULT" target="ACTIVITY" toMany="true">
+		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
+		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
+	</db-relationship>
+	<obj-relationship name="results" source="Activity" target="ActivityResult" collection-type="java.util.Map" map-key="field" deleteRule="Deny" db-relationship-path="ActivityResultsRel"/>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-child-master.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-child-master.map.xml b/cayenne-server/src/test/resources/relationships-child-master.map.xml
new file mode 100644
index 0000000..bf5b391
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-child-master.map.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_child_master"/>
+    <db-entity name="CHILD">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="MASTER_ID" type="INTEGER"/>
+    </db-entity>
+    <db-entity name="MASTER">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" length="100"/>
+    </db-entity>
+    <obj-entity name="Child" className="org.apache.cayenne.testdo.relationships_child_master.Child" dbEntityName="CHILD">
+    </obj-entity>
+    <obj-entity name="Master" className="org.apache.cayenne.testdo.relationships_child_master.Master" dbEntityName="MASTER">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <db-relationship name="master" source="CHILD" target="MASTER" toMany="false">
+        <db-attribute-pair source="MASTER_ID" target="ID"/>
+    </db-relationship>
+    <db-relationship name="children" source="MASTER" target="CHILD" toMany="true">
+        <db-attribute-pair source="ID" target="MASTER_ID"/>
+    </db-relationship>
+    <obj-relationship name="master" source="Child" target="Master" deleteRule="Nullify" db-relationship-path="master"/>
+    <obj-relationship name="children" source="Master" target="Child" deleteRule="Deny" db-relationship-path="children"/>
+
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-clob.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-clob.map.xml b/cayenne-server/src/test/resources/relationships-clob.map.xml
new file mode 100644
index 0000000..9912e4b
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-clob.map.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationship_clob"/>
+    <db-entity name="CLOB_DETAIL">
+        <db-attribute name="CLOB_DETAIL_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="CLOB_MASTER_ID" type="INTEGER"/>
+        <db-attribute name="NAME" type="VARCHAR" length="254"/>
+    </db-entity>
+    <db-entity name="CLOB_MASTER">
+        <db-attribute name="CLOB_COLUMN" type="CLOB"/>
+        <db-attribute name="CLOB_MASTER_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" length="254"/>
+    </db-entity>
+    <obj-entity name="ClobDetail" className="org.apache.cayenne.testdo.relationships_clob.ClobDetail" dbEntityName="CLOB_DETAIL">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="ClobMaster" className="org.apache.cayenne.testdo.relationships_clob.ClobMaster" dbEntityName="CLOB_MASTER">
+        <obj-attribute name="clobColumn" type="java.lang.String" db-attribute-path="CLOB_COLUMN"/>
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <db-relationship name="master" source="CLOB_DETAIL" target="CLOB_MASTER" toMany="false">
+        <db-attribute-pair source="CLOB_MASTER_ID" target="CLOB_MASTER_ID"/>
+    </db-relationship>
+    <db-relationship name="details" source="CLOB_MASTER" target="CLOB_DETAIL" toMany="true">
+        <db-attribute-pair source="CLOB_MASTER_ID" target="CLOB_MASTER_ID"/>
+    </db-relationship>
+    <obj-relationship name="master" source="ClobDetail" target="ClobMaster" db-relationship-path="master"/>
+    <obj-relationship name="details" source="ClobMaster" target="ClobDetail" db-relationship-path="details"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-collection-to-many.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-collection-to-many.map.xml b/cayenne-server/src/test/resources/relationships-collection-to-many.map.xml
new file mode 100644
index 0000000..de7ce49
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-collection-to-many.map.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_collection_to_many"/>
+    <db-entity name="COLLECTION_TO_MANY">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="COLLECTION_TO_MANY_TARGET">
+        <db-attribute name="COLLECTION_TO_MANY_ID" type="INTEGER"/>
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <obj-entity name="CollectionToMany" className="org.apache.cayenne.testdo.relationships_collection_to_many.CollectionToMany" dbEntityName="COLLECTION_TO_MANY">
+    </obj-entity>
+    <obj-entity name="CollectionToManyTarget" className="org.apache.cayenne.testdo.relationships_collection_to_many.CollectionToManyTarget" dbEntityName="COLLECTION_TO_MANY_TARGET">
+    </obj-entity>
+    <db-relationship name="targets" source="COLLECTION_TO_MANY" target="COLLECTION_TO_MANY_TARGET" toMany="true">
+        <db-attribute-pair source="ID" target="COLLECTION_TO_MANY_ID"/>
+    </db-relationship>
+    <db-relationship name="collectionToMany" source="COLLECTION_TO_MANY_TARGET" target="COLLECTION_TO_MANY" toMany="false">
+        <db-attribute-pair source="COLLECTION_TO_MANY_ID" target="ID"/>
+    </db-relationship>
+    <obj-relationship name="targets" source="CollectionToMany" target="CollectionToManyTarget" collection-type="java.util.Collection" db-relationship-path="targets"/>
+    <obj-relationship name="collectionToMany" source="CollectionToManyTarget" target="CollectionToMany" db-relationship-path="collectionToMany"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-delete-rules.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-delete-rules.map.xml b/cayenne-server/src/test/resources/relationships-delete-rules.map.xml
new file mode 100644
index 0000000..4110921
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-delete-rules.map.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_delete_rules"/>
+    <db-entity name="DELETE_RULE_FLATA">
+        <db-attribute name="FLATA_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="DELETE_RULE_FLATB">
+        <db-attribute name="FLATB_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="DELETE_RULE_JOIN">
+        <db-attribute name="FLATA_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="FLATB_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="DELETE_RULE_TEST1">
+        <db-attribute name="DEL_RULE_TEST1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="TEST2_ID" type="INTEGER" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="DELETE_RULE_TEST2">
+        <db-attribute name="DEL_RULE_TEST2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="DELETE_RULE_TEST3">
+        <db-attribute name="DELETE_RULE_TEST_3_FK" type="INTEGER"/>
+        <db-attribute name="DELETE_RULE_TEST_3_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <obj-entity name="DeleteRuleFlatA" className="org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleFlatA" dbEntityName="DELETE_RULE_FLATA">
+    </obj-entity>
+    <obj-entity name="DeleteRuleFlatB" className="org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleFlatB" dbEntityName="DELETE_RULE_FLATB">
+    </obj-entity>
+    <obj-entity name="DeleteRuleTest1" className="org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleTest1" dbEntityName="DELETE_RULE_TEST1">
+    </obj-entity>
+    <obj-entity name="DeleteRuleTest2" className="org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleTest2" dbEntityName="DELETE_RULE_TEST2">
+    </obj-entity>
+    <obj-entity name="DeleteRuleTest3" className="org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleTest3" dbEntityName="DELETE_RULE_TEST3">
+    </obj-entity>
+    <db-relationship name="joins" source="DELETE_RULE_FLATA" target="DELETE_RULE_JOIN" toDependentPK="true" toMany="true">
+        <db-attribute-pair source="FLATA_ID" target="FLATA_ID"/>
+    </db-relationship>
+    <db-relationship name="joins" source="DELETE_RULE_FLATB" target="DELETE_RULE_JOIN" toDependentPK="true" toMany="true">
+        <db-attribute-pair source="FLATB_ID" target="FLATB_ID"/>
+    </db-relationship>
+    <db-relationship name="toFlatA" source="DELETE_RULE_JOIN" target="DELETE_RULE_FLATA" toMany="false">
+        <db-attribute-pair source="FLATA_ID" target="FLATA_ID"/>
+    </db-relationship>
+    <db-relationship name="toFlatB" source="DELETE_RULE_JOIN" target="DELETE_RULE_FLATB" toMany="false">
+        <db-attribute-pair source="FLATB_ID" target="FLATB_ID"/>
+    </db-relationship>
+    <db-relationship name="deleteRuleTest3Array" source="DELETE_RULE_TEST1" target="DELETE_RULE_TEST3" toMany="true">
+        <db-attribute-pair source="DEL_RULE_TEST1_ID" target="DELETE_RULE_TEST_3_FK"/>
+    </db-relationship>
+    <db-relationship name="test2" source="DELETE_RULE_TEST1" target="DELETE_RULE_TEST2" toMany="false">
+        <db-attribute-pair source="TEST2_ID" target="DEL_RULE_TEST2_ID"/>
+    </db-relationship>
+    <db-relationship name="deleteRuleTest3Array" source="DELETE_RULE_TEST2" target="DELETE_RULE_TEST3" toMany="true">
+        <db-attribute-pair source="DEL_RULE_TEST2_ID" target="DELETE_RULE_TEST_3_FK"/>
+    </db-relationship>
+    <db-relationship name="test1Array" source="DELETE_RULE_TEST2" target="DELETE_RULE_TEST1" toMany="true">
+        <db-attribute-pair source="DEL_RULE_TEST2_ID" target="TEST2_ID"/>
+    </db-relationship>
+    <db-relationship name="toDeleteRuleTest2" source="DELETE_RULE_TEST3" target="DELETE_RULE_TEST2" toMany="false">
+        <db-attribute-pair source="DELETE_RULE_TEST_3_FK" target="DEL_RULE_TEST2_ID"/>
+    </db-relationship>
+    <obj-relationship name="flatB" source="DeleteRuleFlatA" target="DeleteRuleFlatB" db-relationship-path="joins.toFlatB"/>
+    <obj-relationship name="untitledRel" source="DeleteRuleFlatB" target="DeleteRuleFlatA" db-relationship-path="joins.toFlatA"/>
+    <obj-relationship name="test2" source="DeleteRuleTest1" target="DeleteRuleTest2" deleteRule="Deny" db-relationship-path="test2"/>
+    <obj-relationship name="deleteRuleTest3Array" source="DeleteRuleTest2" target="DeleteRuleTest3" db-relationship-path="deleteRuleTest3Array"/>
+    <obj-relationship name="test1Array" source="DeleteRuleTest2" target="DeleteRuleTest1" deleteRule="Nullify" db-relationship-path="test1Array"/>
+    <obj-relationship name="toDeleteRuleTest2" source="DeleteRuleTest3" target="DeleteRuleTest2" db-relationship-path="toDeleteRuleTest2"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-flattened.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-flattened.map.xml b/cayenne-server/src/test/resources/relationships-flattened.map.xml
new file mode 100644
index 0000000..c032f55
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-flattened.map.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationship_flattened"/>
+    <db-entity name="COMPLEX_JOIN">
+        <db-attribute name="EXTRA_COLUMN" type="VARCHAR" length="50"/>
+        <db-attribute name="FT1_FK" type="INTEGER"/>
+        <db-attribute name="FT3_FK" type="INTEGER"/>
+        <db-attribute name="PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="FLATTENED_CIRCULAR">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="FLATTENED_CIRCULAR_JOIN">
+        <db-attribute name="SIDE1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="SIDE2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="FLATTENED_TEST_1">
+        <db-attribute name="FT1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+    </db-entity>
+    <db-entity name="FLATTENED_TEST_2">
+        <db-attribute name="FT1_ID" type="INTEGER"/>
+        <db-attribute name="FT2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+    </db-entity>
+    <db-entity name="FLATTENED_TEST_3">
+        <db-attribute name="FT2_ID" type="INTEGER"/>
+        <db-attribute name="FT3_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+    </db-entity>
+    <db-entity name="FLATTENED_TEST_4">
+        <db-attribute name="FT3_ID" type="INTEGER"/>
+        <db-attribute name="FT4_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+    </db-entity>
+    <obj-entity name="FlattenedCircular" className="org.apache.cayenne.testdo.relationships_flattened.FlattenedCircular" dbEntityName="FLATTENED_CIRCULAR">
+    </obj-entity>
+    <obj-entity name="FlattenedTest1" className="org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1" dbEntityName="FLATTENED_TEST_1">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="FlattenedTest2" className="org.apache.cayenne.testdo.relationships_flattened.FlattenedTest2" dbEntityName="FLATTENED_TEST_2">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="FlattenedTest3" className="org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3" dbEntityName="FLATTENED_TEST_3">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="FlattenedTest4" className="org.apache.cayenne.testdo.relationships_flattened.FlattenedTest4" dbEntityName="FLATTENED_TEST_4">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <db-relationship name="toFT1" source="COMPLEX_JOIN" target="FLATTENED_TEST_1" toMany="false">
+        <db-attribute-pair source="FT1_FK" target="FT1_ID"/>
+    </db-relationship>
+    <db-relationship name="toFT3" source="COMPLEX_JOIN" target="FLATTENED_TEST_3" toMany="false">
+        <db-attribute-pair source="FT3_FK" target="FT3_ID"/>
+    </db-relationship>
+    <db-relationship name="side1s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN" toDependentPK="true" toMany="true">
+        <db-attribute-pair source="ID" target="SIDE2_ID"/>
+    </db-relationship>
+    <db-relationship name="side2s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN" toDependentPK="true" toMany="true">
+        <db-attribute-pair source="ID" target="SIDE1_ID"/>
+    </db-relationship>
+    <db-relationship name="side1" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR" toMany="false">
+        <db-attribute-pair source="SIDE1_ID" target="ID"/>
+    </db-relationship>
+    <db-relationship name="side2" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR" toMany="false">
+        <db-attribute-pair source="SIDE2_ID" target="ID"/>
+    </db-relationship>
+    <db-relationship name="complexJoins" source="FLATTENED_TEST_1" target="COMPLEX_JOIN" toMany="true">
+        <db-attribute-pair source="FT1_ID" target="FT1_FK"/>
+    </db-relationship>
+    <db-relationship name="ft2Array" source="FLATTENED_TEST_1" target="FLATTENED_TEST_2" toMany="true">
+        <db-attribute-pair source="FT1_ID" target="FT1_ID"/>
+    </db-relationship>
+    <db-relationship name="ft3Array" source="FLATTENED_TEST_2" target="FLATTENED_TEST_3" toMany="true">
+        <db-attribute-pair source="FT2_ID" target="FT2_ID"/>
+    </db-relationship>
+    <db-relationship name="toFT1" source="FLATTENED_TEST_2" target="FLATTENED_TEST_1" toMany="false">
+        <db-attribute-pair source="FT1_ID" target="FT1_ID"/>
+    </db-relationship>
+    <db-relationship name="complexJoins" source="FLATTENED_TEST_3" target="COMPLEX_JOIN" toMany="true">
+        <db-attribute-pair source="FT3_ID" target="FT3_FK"/>
+    </db-relationship>
+    <db-relationship name="ft4Array" source="FLATTENED_TEST_3" target="FLATTENED_TEST_4" toMany="true">
+        <db-attribute-pair source="FT3_ID" target="FT3_ID"/>
+    </db-relationship>
+    <db-relationship name="toFT2" source="FLATTENED_TEST_3" target="FLATTENED_TEST_2" toMany="false">
+        <db-attribute-pair source="FT2_ID" target="FT2_ID"/>
+    </db-relationship>
+    <db-relationship name="toFT3" source="FLATTENED_TEST_4" target="FLATTENED_TEST_3" toMany="false">
+        <db-attribute-pair source="FT3_ID" target="FT3_ID"/>
+    </db-relationship>
+    <obj-relationship name="side1s" source="FlattenedCircular" target="FlattenedCircular" db-relationship-path="side1s.side1"/>
+    <obj-relationship name="side2s" source="FlattenedCircular" target="FlattenedCircular" db-relationship-path="side2s.side2"/>
+    <obj-relationship name="ft2Array" source="FlattenedTest1" target="FlattenedTest2" db-relationship-path="ft2Array"/>
+    <obj-relationship name="ft3Array" source="FlattenedTest1" target="FlattenedTest3" db-relationship-path="ft2Array.ft3Array"/>
+    <obj-relationship name="ft3OverComplex" source="FlattenedTest1" target="FlattenedTest3" db-relationship-path="complexJoins.toFT3"/>
+    <obj-relationship name="ft4ArrayFor1" source="FlattenedTest1" target="FlattenedTest4" db-relationship-path="ft2Array.ft3Array.ft4Array"/>
+    <obj-relationship name="ft3Array" source="FlattenedTest2" target="FlattenedTest3" db-relationship-path="ft3Array"/>
+    <obj-relationship name="toFT1" source="FlattenedTest2" target="FlattenedTest1" db-relationship-path="toFT1"/>
+    <obj-relationship name="ft4Array" source="FlattenedTest3" target="FlattenedTest4" db-relationship-path="ft4Array"/>
+    <obj-relationship name="toFT1" source="FlattenedTest3" target="FlattenedTest1" db-relationship-path="toFT2.toFT1"/>
+    <obj-relationship name="toFT2" source="FlattenedTest3" target="FlattenedTest2" db-relationship-path="toFT2"/>
+    <obj-relationship name="toFT3" source="FlattenedTest4" target="FlattenedTest3" db-relationship-path="toFT3"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-set-to-many.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-set-to-many.map.xml b/cayenne-server/src/test/resources/relationships-set-to-many.map.xml
new file mode 100644
index 0000000..6e1de37
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-set-to-many.map.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_set_to_many"/>
+    <db-entity name="SET_TO_MANY">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="SET_TO_MANY_TARGET">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="SET_TO_MANY_ID" type="INTEGER"/>
+    </db-entity>
+    <obj-entity name="SetToMany" className="org.apache.cayenne.testdo.relationships_set_to_many.SetToMany" dbEntityName="SET_TO_MANY">
+    </obj-entity>
+    <obj-entity name="SetToManyTarget" className="org.apache.cayenne.testdo.relationships_set_to_many.SetToManyTarget" dbEntityName="SET_TO_MANY_TARGET">
+    </obj-entity>
+    <db-relationship name="targets" source="SET_TO_MANY" target="SET_TO_MANY_TARGET" toMany="true">
+        <db-attribute-pair source="ID" target="SET_TO_MANY_ID"/>
+    </db-relationship>
+    <db-relationship name="setToMany" source="SET_TO_MANY_TARGET" target="SET_TO_MANY" toMany="false">
+        <db-attribute-pair source="SET_TO_MANY_ID" target="ID"/>
+    </db-relationship>
+    <obj-relationship name="targets" source="SetToMany" target="SetToManyTarget" collection-type="java.util.Set" db-relationship-path="targets"/>
+    <obj-relationship name="setToMany" source="SetToManyTarget" target="SetToMany" db-relationship-path="setToMany"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-to-many-fk.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-to-many-fk.map.xml b/cayenne-server/src/test/resources/relationships-to-many-fk.map.xml
new file mode 100644
index 0000000..0a6d575
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-to-many-fk.map.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_to_many_fk"/>
+    <db-entity name="TO_MANY_FKDEP">
+        <db-attribute name="DEP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" length="200"/>
+        <db-attribute name="OTHER_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="TO_MANY_FKROOT">
+        <db-attribute name="FK_ID" type="INTEGER"/>
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" length="100"/>
+    </db-entity>
+    <db-entity name="TO_MANY_ROOT2">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+        <db-attribute name="NAME" type="VARCHAR" length="100"/>
+    </db-entity>
+    <obj-entity name="ToManyFkDep" className="org.apache.cayenne.testdo.relationships_to_many_fk.ToManyFkDep" dbEntityName="TO_MANY_FKDEP">
+        <obj-attribute name="depId" type="java.lang.Integer" db-attribute-path="DEP_ID"/>
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="ToManyFkRoot" className="org.apache.cayenne.testdo.relationships_to_many_fk.ToManyFkRoot" dbEntityName="TO_MANY_FKROOT">
+        <obj-attribute name="depId" type="java.lang.Integer" db-attribute-path="FK_ID"/>
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <obj-entity name="ToManyRoot2" className="org.apache.cayenne.testdo.relationships_to_many_fk.ToManyRoot2" dbEntityName="TO_MANY_ROOT2">
+        <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+    </obj-entity>
+    <db-relationship name="root" source="TO_MANY_FKDEP" target="TO_MANY_FKROOT" toMany="false">
+        <db-attribute-pair source="DEP_ID" target="FK_ID"/>
+    </db-relationship>
+    <db-relationship name="root2" source="TO_MANY_FKDEP" target="TO_MANY_ROOT2" toMany="false">
+        <db-attribute-pair source="OTHER_ID" target="ID"/>
+    </db-relationship>
+    <db-relationship name="deps" source="TO_MANY_FKROOT" target="TO_MANY_FKDEP" toMany="true">
+        <db-attribute-pair source="FK_ID" target="DEP_ID"/>
+    </db-relationship>
+    <db-relationship name="deps" source="TO_MANY_ROOT2" target="TO_MANY_FKDEP" toDependentPK="true" toMany="true">
+        <db-attribute-pair source="ID" target="OTHER_ID"/>
+    </db-relationship>
+    <obj-relationship name="root" source="ToManyFkDep" target="ToManyFkRoot" db-relationship-path="root"/>
+    <obj-relationship name="root2" source="ToManyFkDep" target="ToManyRoot2" db-relationship-path="root2"/>
+    <obj-relationship name="deps" source="ToManyFkRoot" target="ToManyFkDep" db-relationship-path="deps"/>
+    <obj-relationship name="deps" source="ToManyRoot2" target="ToManyFkDep" db-relationship-path="deps"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships-to-one-fk.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships-to-one-fk.map.xml b/cayenne-server/src/test/resources/relationships-to-one-fk.map.xml
new file mode 100644
index 0000000..70393ea
--- /dev/null
+++ b/cayenne-server/src/test/resources/relationships-to-one-fk.map.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="org.apache.cayenne.testdo.relationships_to_one_fk"/>
+    <db-entity name="TO_ONE_FK1">
+        <db-attribute name="TO_ONE_FK1_FK" type="INTEGER" isMandatory="true"/>
+        <db-attribute name="TO_ONE_FK1_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <db-entity name="TO_ONE_FK2">
+        <db-attribute name="TO_ONE_FK2_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+    </db-entity>
+    <obj-entity name="ToOneFK1" className="org.apache.cayenne.testdo.relationships_to_one_fk.ToOneFK1" dbEntityName="TO_ONE_FK1">
+    </obj-entity>
+    <obj-entity name="ToOneFK2" className="org.apache.cayenne.testdo.relationships_to_one_fk.ToOneFK2" dbEntityName="TO_ONE_FK2">
+    </obj-entity>
+    <db-relationship name="toPK" source="TO_ONE_FK1" target="TO_ONE_FK2" toMany="false">
+        <db-attribute-pair source="TO_ONE_FK1_FK" target="TO_ONE_FK2_PK"/>
+    </db-relationship>
+    <db-relationship name="toOneToFK" source="TO_ONE_FK2" target="TO_ONE_FK1" toMany="false">
+        <db-attribute-pair source="TO_ONE_FK2_PK" target="TO_ONE_FK1_FK"/>
+    </db-relationship>
+    <obj-relationship name="toPK" source="ToOneFK1" target="ToOneFK2" db-relationship-path="toPK"/>
+    <obj-relationship name="toOneToFK" source="ToOneFK2" target="ToOneFK1" db-relationship-path="toOneToFK"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships.map.xml b/cayenne-server/src/test/resources/relationships.map.xml
index 85ce607..ec20cc7 100644
--- a/cayenne-server/src/test/resources/relationships.map.xml
+++ b/cayenne-server/src/test/resources/relationships.map.xml
@@ -3,89 +3,11 @@
 	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
 	 project-version="7">
-	<property name="defaultPackage" value="org.apache.cayenne.testdo.relationship"/>
-	<db-entity name="CHILD">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="MASTER_ID" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="CLOB_DETAIL">
-		<db-attribute name="CLOB_DETAIL_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="CLOB_MASTER_ID" type="INTEGER"/>
-		<db-attribute name="NAME" type="VARCHAR" length="254"/>
-	</db-entity>
-	<db-entity name="CLOB_MASTER">
-		<db-attribute name="CLOB_COLUMN" type="CLOB"/>
-		<db-attribute name="CLOB_MASTER_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="254"/>
-	</db-entity>
-	<db-entity name="COLLECTION_TO_MANY">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="COLLECTION_TO_MANY_TARGET">
-		<db-attribute name="COLLECTION_TO_MANY_ID" type="INTEGER"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="COMPLEX_JOIN">
-		<db-attribute name="EXTRA_COLUMN" type="VARCHAR" length="50"/>
-		<db-attribute name="FT1_FK" type="INTEGER"/>
-		<db-attribute name="FT3_FK" type="INTEGER"/>
-		<db-attribute name="PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_FLATA">
-		<db-attribute name="FLATA_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_FLATB">
-		<db-attribute name="FLATB_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_JOIN">
-		<db-attribute name="FLATA_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="FLATB_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_TEST1">
-		<db-attribute name="DEL_RULE_TEST1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="TEST2_ID" type="INTEGER" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_TEST2">
-		<db-attribute name="DEL_RULE_TEST2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="DELETE_RULE_TEST3">
-		<db-attribute name="DELETE_RULE_TEST_3_FK" type="INTEGER"/>
-		<db-attribute name="DELETE_RULE_TEST_3_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.relationships"/>
 	<db-entity name="FK_OF_DIFFERENT_TYPE">
 		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="RELATIONSHIP_HELPER_FK" type="SMALLINT"/>
 	</db-entity>
-	<db-entity name="FLATTENED_CIRCULAR">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="FLATTENED_CIRCULAR_JOIN">
-		<db-attribute name="SIDE1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="SIDE2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="FLATTENED_TEST_1">
-		<db-attribute name="FT1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-	</db-entity>
-	<db-entity name="FLATTENED_TEST_2">
-		<db-attribute name="FT1_ID" type="INTEGER"/>
-		<db-attribute name="FT2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-	</db-entity>
-	<db-entity name="FLATTENED_TEST_3">
-		<db-attribute name="FT2_ID" type="INTEGER"/>
-		<db-attribute name="FT3_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-	</db-entity>
-	<db-entity name="FLATTENED_TEST_4">
-		<db-attribute name="FT3_ID" type="INTEGER"/>
-		<db-attribute name="FT4_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-	</db-entity>
-	<db-entity name="MASTER">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
 	<db-entity name="MEANINGFUL_FK">
 		<db-attribute name="MEANIGNFUL_FK_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="RELATIONSHIP_HELPER_ID" type="INTEGER" isMandatory="true"/>
@@ -100,194 +22,20 @@
 		<db-attribute name="NAME" type="VARCHAR" length="100"/>
 		<db-attribute name="RELATIONSHIP_HELPER_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 	</db-entity>
-	<db-entity name="SET_TO_MANY">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="SET_TO_MANY_TARGET">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="SET_TO_MANY_ID" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="TO_MANY_FKDEP">
-		<db-attribute name="DEP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="200"/>
-		<db-attribute name="OTHER_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="TO_MANY_FKROOT">
-		<db-attribute name="FK_ID" type="INTEGER"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="TO_MANY_ROOT2">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="TO_ONEFK1">
-		<db-attribute name="TO_ONEFK1_FK" type="INTEGER" isMandatory="true"/>
-		<db-attribute name="TO_ONEFK1_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="TO_ONEFK2">
-		<db-attribute name="TO_ONEFK2_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<obj-entity name="Child" className="org.apache.cayenne.testdo.relationship.Child" dbEntityName="CHILD">
-	</obj-entity>
-	<obj-entity name="ClobDetail" className="org.apache.cayenne.testdo.relationship.ClobDetail" dbEntityName="CLOB_DETAIL">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="ClobMaster" className="org.apache.cayenne.testdo.relationship.ClobMaster" dbEntityName="CLOB_MASTER">
-		<obj-attribute name="clobColumn" type="java.lang.String" db-attribute-path="CLOB_COLUMN"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="CollectionToMany" className="org.apache.cayenne.testdo.relationship.CollectionToMany" dbEntityName="COLLECTION_TO_MANY">
-	</obj-entity>
-	<obj-entity name="CollectionToManyTarget" className="org.apache.cayenne.testdo.relationship.CollectionToManyTarget" dbEntityName="COLLECTION_TO_MANY_TARGET">
-	</obj-entity>
-	<obj-entity name="DeleteRuleFlatA" className="org.apache.cayenne.testdo.relationship.DeleteRuleFlatA" dbEntityName="DELETE_RULE_FLATA">
-	</obj-entity>
-	<obj-entity name="DeleteRuleFlatB" className="org.apache.cayenne.testdo.relationship.DeleteRuleFlatB" dbEntityName="DELETE_RULE_FLATB">
-	</obj-entity>
-	<obj-entity name="DeleteRuleTest1" className="org.apache.cayenne.testdo.relationship.DeleteRuleTest1" dbEntityName="DELETE_RULE_TEST1">
-	</obj-entity>
-	<obj-entity name="DeleteRuleTest2" className="org.apache.cayenne.testdo.relationship.DeleteRuleTest2" dbEntityName="DELETE_RULE_TEST2">
-	</obj-entity>
-	<obj-entity name="DeleteRuleTest3" className="org.apache.cayenne.testdo.relationship.DeleteRuleTest3" dbEntityName="DELETE_RULE_TEST3">
-	</obj-entity>
-	<obj-entity name="FkOfDifferentType" className="org.apache.cayenne.testdo.relationship.FkOfDifferentType" dbEntityName="FK_OF_DIFFERENT_TYPE">
-	</obj-entity>
-	<obj-entity name="FlattenedCircular" className="org.apache.cayenne.testdo.relationship.FlattenedCircular" dbEntityName="FLATTENED_CIRCULAR">
-	</obj-entity>
-	<obj-entity name="FlattenedTest1" className="org.apache.cayenne.testdo.relationship.FlattenedTest1" dbEntityName="FLATTENED_TEST_1">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="FlattenedTest2" className="org.apache.cayenne.testdo.relationship.FlattenedTest2" dbEntityName="FLATTENED_TEST_2">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="FlattenedTest3" className="org.apache.cayenne.testdo.relationship.FlattenedTest3" dbEntityName="FLATTENED_TEST_3">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="FlattenedTest4" className="org.apache.cayenne.testdo.relationship.FlattenedTest4" dbEntityName="FLATTENED_TEST_4">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="Master" className="org.apache.cayenne.testdo.relationship.Master" dbEntityName="MASTER">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	<obj-entity name="FkOfDifferentType" className="org.apache.cayenne.testdo.relationships.FkOfDifferentType" dbEntityName="FK_OF_DIFFERENT_TYPE">
 	</obj-entity>
-	<obj-entity name="MeaningfulFK" className="org.apache.cayenne.testdo.relationship.MeaningfulFK" dbEntityName="MEANINGFUL_FK">
+	<obj-entity name="MeaningfulFK" className="org.apache.cayenne.testdo.relationships.MeaningfulFK" dbEntityName="MEANINGFUL_FK">
 		<obj-attribute name="relationshipHelperID" type="java.lang.Integer" db-attribute-path="RELATIONSHIP_HELPER_ID"/>
 	</obj-entity>
-	<obj-entity name="ReflexiveAndToOne" className="org.apache.cayenne.testdo.relationship.ReflexiveAndToOne" dbEntityName="REFLEXIVE_AND_TO_ONE">
+	<obj-entity name="ReflexiveAndToOne" className="org.apache.cayenne.testdo.relationships.ReflexiveAndToOne" dbEntityName="REFLEXIVE_AND_TO_ONE">
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
 	</obj-entity>
-	<obj-entity name="RelationshipHelper" className="org.apache.cayenne.testdo.relationship.RelationshipHelper" dbEntityName="RELATIONSHIP_HELPER">
+	<obj-entity name="RelationshipHelper" className="org.apache.cayenne.testdo.relationships.RelationshipHelper" dbEntityName="RELATIONSHIP_HELPER">
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
 	</obj-entity>
-	<obj-entity name="SetToMany" className="org.apache.cayenne.testdo.relationship.SetToMany" dbEntityName="SET_TO_MANY">
-	</obj-entity>
-	<obj-entity name="SetToManyTarget" className="org.apache.cayenne.testdo.relationship.SetToManyTarget" dbEntityName="SET_TO_MANY_TARGET">
-	</obj-entity>
-	<obj-entity name="ToManyFkDep" className="org.apache.cayenne.testdo.relationship.ToManyFkDep" dbEntityName="TO_MANY_FKDEP">
-		<obj-attribute name="depId" type="java.lang.Integer" db-attribute-path="DEP_ID"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="ToManyFkRoot" className="org.apache.cayenne.testdo.relationship.ToManyFkRoot" dbEntityName="TO_MANY_FKROOT">
-		<obj-attribute name="depId" type="java.lang.Integer" db-attribute-path="FK_ID"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="ToManyRoot2" className="org.apache.cayenne.testdo.relationship.ToManyRoot2" dbEntityName="TO_MANY_ROOT2">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="ToOneFK1" className="org.apache.cayenne.testdo.relationship.ToOneFK1" dbEntityName="TO_ONEFK1">
-	</obj-entity>
-	<obj-entity name="ToOneFK2" className="org.apache.cayenne.testdo.relationship.ToOneFK2" dbEntityName="TO_ONEFK2">
-	</obj-entity>
-	<db-relationship name="master" source="CHILD" target="MASTER" toMany="false">
-		<db-attribute-pair source="MASTER_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="master" source="CLOB_DETAIL" target="CLOB_MASTER" toMany="false">
-		<db-attribute-pair source="CLOB_MASTER_ID" target="CLOB_MASTER_ID"/>
-	</db-relationship>
-	<db-relationship name="details" source="CLOB_MASTER" target="CLOB_DETAIL" toMany="true">
-		<db-attribute-pair source="CLOB_MASTER_ID" target="CLOB_MASTER_ID"/>
-	</db-relationship>
-	<db-relationship name="targets" source="COLLECTION_TO_MANY" target="COLLECTION_TO_MANY_TARGET" toMany="true">
-		<db-attribute-pair source="ID" target="COLLECTION_TO_MANY_ID"/>
-	</db-relationship>
-	<db-relationship name="collectionToMany" source="COLLECTION_TO_MANY_TARGET" target="COLLECTION_TO_MANY" toMany="false">
-		<db-attribute-pair source="COLLECTION_TO_MANY_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="toFT1" source="COMPLEX_JOIN" target="FLATTENED_TEST_1" toMany="false">
-		<db-attribute-pair source="FT1_FK" target="FT1_ID"/>
-	</db-relationship>
-	<db-relationship name="toFT3" source="COMPLEX_JOIN" target="FLATTENED_TEST_3" toMany="false">
-		<db-attribute-pair source="FT3_FK" target="FT3_ID"/>
-	</db-relationship>
-	<db-relationship name="joins" source="DELETE_RULE_FLATA" target="DELETE_RULE_JOIN" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="FLATA_ID" target="FLATA_ID"/>
-	</db-relationship>
-	<db-relationship name="joins" source="DELETE_RULE_FLATB" target="DELETE_RULE_JOIN" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="FLATB_ID" target="FLATB_ID"/>
-	</db-relationship>
-	<db-relationship name="toFlatA" source="DELETE_RULE_JOIN" target="DELETE_RULE_FLATA" toMany="false">
-		<db-attribute-pair source="FLATA_ID" target="FLATA_ID"/>
-	</db-relationship>
-	<db-relationship name="toFlatB" source="DELETE_RULE_JOIN" target="DELETE_RULE_FLATB" toMany="false">
-		<db-attribute-pair source="FLATB_ID" target="FLATB_ID"/>
-	</db-relationship>
-	<db-relationship name="deleteRuleTest3Array" source="DELETE_RULE_TEST1" target="DELETE_RULE_TEST3" toMany="true">
-		<db-attribute-pair source="DEL_RULE_TEST1_ID" target="DELETE_RULE_TEST_3_FK"/>
-	</db-relationship>
-	<db-relationship name="test2" source="DELETE_RULE_TEST1" target="DELETE_RULE_TEST2" toMany="false">
-		<db-attribute-pair source="TEST2_ID" target="DEL_RULE_TEST2_ID"/>
-	</db-relationship>
-	<db-relationship name="deleteRuleTest3Array" source="DELETE_RULE_TEST2" target="DELETE_RULE_TEST3" toMany="true">
-		<db-attribute-pair source="DEL_RULE_TEST2_ID" target="DELETE_RULE_TEST_3_FK"/>
-	</db-relationship>
-	<db-relationship name="test1Array" source="DELETE_RULE_TEST2" target="DELETE_RULE_TEST1" toMany="true">
-		<db-attribute-pair source="DEL_RULE_TEST2_ID" target="TEST2_ID"/>
-	</db-relationship>
-	<db-relationship name="toDeleteRuleTest2" source="DELETE_RULE_TEST3" target="DELETE_RULE_TEST2" toMany="false">
-		<db-attribute-pair source="DELETE_RULE_TEST_3_FK" target="DEL_RULE_TEST2_ID"/>
-	</db-relationship>
 	<db-relationship name="relationshipHelper" source="FK_OF_DIFFERENT_TYPE" target="RELATIONSHIP_HELPER" toMany="false">
 		<db-attribute-pair source="RELATIONSHIP_HELPER_FK" target="RELATIONSHIP_HELPER_ID"/>
 	</db-relationship>
-	<db-relationship name="side1s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="ID" target="SIDE2_ID"/>
-	</db-relationship>
-	<db-relationship name="side2s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="ID" target="SIDE1_ID"/>
-	</db-relationship>
-	<db-relationship name="side1" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR" toMany="false">
-		<db-attribute-pair source="SIDE1_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="side2" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR" toMany="false">
-		<db-attribute-pair source="SIDE2_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="complexJoins" source="FLATTENED_TEST_1" target="COMPLEX_JOIN" toMany="true">
-		<db-attribute-pair source="FT1_ID" target="FT1_FK"/>
-	</db-relationship>
-	<db-relationship name="ft2Array" source="FLATTENED_TEST_1" target="FLATTENED_TEST_2" toMany="true">
-		<db-attribute-pair source="FT1_ID" target="FT1_ID"/>
-	</db-relationship>
-	<db-relationship name="ft3Array" source="FLATTENED_TEST_2" target="FLATTENED_TEST_3" toMany="true">
-		<db-attribute-pair source="FT2_ID" target="FT2_ID"/>
-	</db-relationship>
-	<db-relationship name="toFT1" source="FLATTENED_TEST_2" target="FLATTENED_TEST_1" toMany="false">
-		<db-attribute-pair source="FT1_ID" target="FT1_ID"/>
-	</db-relationship>
-	<db-relationship name="complexJoins" source="FLATTENED_TEST_3" target="COMPLEX_JOIN" toMany="true">
-		<db-attribute-pair source="FT3_ID" target="FT3_FK"/>
-	</db-relationship>
-	<db-relationship name="ft4Array" source="FLATTENED_TEST_3" target="FLATTENED_TEST_4" toMany="true">
-		<db-attribute-pair source="FT3_ID" target="FT3_ID"/>
-	</db-relationship>
-	<db-relationship name="toFT2" source="FLATTENED_TEST_3" target="FLATTENED_TEST_2" toMany="false">
-		<db-attribute-pair source="FT2_ID" target="FT2_ID"/>
-	</db-relationship>
-	<db-relationship name="toFT3" source="FLATTENED_TEST_4" target="FLATTENED_TEST_3" toMany="false">
-		<db-attribute-pair source="FT3_ID" target="FT3_ID"/>
-	</db-relationship>
-	<db-relationship name="children" source="MASTER" target="CHILD" toMany="true">
-		<db-attribute-pair source="ID" target="MASTER_ID"/>
-	</db-relationship>
 	<db-relationship name="toRelationshipHelper" source="MEANINGFUL_FK" target="RELATIONSHIP_HELPER" toMany="false">
 		<db-attribute-pair source="RELATIONSHIP_HELPER_ID" target="RELATIONSHIP_HELPER_ID"/>
 	</db-relationship>
@@ -309,55 +57,7 @@
 	<db-relationship name="reflexiveAndToOneArray" source="RELATIONSHIP_HELPER" target="REFLEXIVE_AND_TO_ONE" toMany="true">
 		<db-attribute-pair source="RELATIONSHIP_HELPER_ID" target="RELATIONSHIP_HELPER_ID"/>
 	</db-relationship>
-	<db-relationship name="targets" source="SET_TO_MANY" target="SET_TO_MANY_TARGET" toMany="true">
-		<db-attribute-pair source="ID" target="SET_TO_MANY_ID"/>
-	</db-relationship>
-	<db-relationship name="setToMany" source="SET_TO_MANY_TARGET" target="SET_TO_MANY" toMany="false">
-		<db-attribute-pair source="SET_TO_MANY_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="root" source="TO_MANY_FKDEP" target="TO_MANY_FKROOT" toMany="false">
-		<db-attribute-pair source="DEP_ID" target="FK_ID"/>
-	</db-relationship>
-	<db-relationship name="root2" source="TO_MANY_FKDEP" target="TO_MANY_ROOT2" toMany="false">
-		<db-attribute-pair source="OTHER_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="deps" source="TO_MANY_FKROOT" target="TO_MANY_FKDEP" toMany="true">
-		<db-attribute-pair source="FK_ID" target="DEP_ID"/>
-	</db-relationship>
-	<db-relationship name="deps" source="TO_MANY_ROOT2" target="TO_MANY_FKDEP" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="ID" target="OTHER_ID"/>
-	</db-relationship>
-	<db-relationship name="toPK" source="TO_ONEFK1" target="TO_ONEFK2" toMany="false">
-		<db-attribute-pair source="TO_ONEFK1_FK" target="TO_ONEFK2_PK"/>
-	</db-relationship>
-	<db-relationship name="toOneToFK" source="TO_ONEFK2" target="TO_ONEFK1" toMany="false">
-		<db-attribute-pair source="TO_ONEFK2_PK" target="TO_ONEFK1_FK"/>
-	</db-relationship>
-	<obj-relationship name="master" source="Child" target="Master" deleteRule="Nullify" db-relationship-path="master"/>
-	<obj-relationship name="master" source="ClobDetail" target="ClobMaster" db-relationship-path="master"/>
-	<obj-relationship name="details" source="ClobMaster" target="ClobDetail" db-relationship-path="details"/>
-	<obj-relationship name="targets" source="CollectionToMany" target="CollectionToManyTarget" collection-type="java.util.Collection" db-relationship-path="targets"/>
-	<obj-relationship name="collectionToMany" source="CollectionToManyTarget" target="CollectionToMany" db-relationship-path="collectionToMany"/>
-	<obj-relationship name="flatB" source="DeleteRuleFlatA" target="DeleteRuleFlatB" db-relationship-path="joins.toFlatB"/>
-	<obj-relationship name="untitledRel" source="DeleteRuleFlatB" target="DeleteRuleFlatA" db-relationship-path="joins.toFlatA"/>
-	<obj-relationship name="test2" source="DeleteRuleTest1" target="DeleteRuleTest2" deleteRule="Deny" db-relationship-path="test2"/>
-	<obj-relationship name="deleteRuleTest3Array" source="DeleteRuleTest2" target="DeleteRuleTest3" db-relationship-path="deleteRuleTest3Array"/>
-	<obj-relationship name="test1Array" source="DeleteRuleTest2" target="DeleteRuleTest1" deleteRule="Nullify" db-relationship-path="test1Array"/>
-	<obj-relationship name="toDeleteRuleTest2" source="DeleteRuleTest3" target="DeleteRuleTest2" db-relationship-path="toDeleteRuleTest2"/>
 	<obj-relationship name="relationshipHelper" source="FkOfDifferentType" target="RelationshipHelper" db-relationship-path="relationshipHelper"/>
-	<obj-relationship name="side1s" source="FlattenedCircular" target="FlattenedCircular" db-relationship-path="side1s.side1"/>
-	<obj-relationship name="side2s" source="FlattenedCircular" target="FlattenedCircular" db-relationship-path="side2s.side2"/>
-	<obj-relationship name="ft2Array" source="FlattenedTest1" target="FlattenedTest2" db-relationship-path="ft2Array"/>
-	<obj-relationship name="ft3Array" source="FlattenedTest1" target="FlattenedTest3" db-relationship-path="ft2Array.ft3Array"/>
-	<obj-relationship name="ft3OverComplex" source="FlattenedTest1" target="FlattenedTest3" db-relationship-path="complexJoins.toFT3"/>
-	<obj-relationship name="ft4ArrayFor1" source="FlattenedTest1" target="FlattenedTest4" db-relationship-path="ft2Array.ft3Array.ft4Array"/>
-	<obj-relationship name="ft3Array" source="FlattenedTest2" target="FlattenedTest3" db-relationship-path="ft3Array"/>
-	<obj-relationship name="toFT1" source="FlattenedTest2" target="FlattenedTest1" db-relationship-path="toFT1"/>
-	<obj-relationship name="ft4Array" source="FlattenedTest3" target="FlattenedTest4" db-relationship-path="ft4Array"/>
-	<obj-relationship name="toFT1" source="FlattenedTest3" target="FlattenedTest1" db-relationship-path="toFT2.toFT1"/>
-	<obj-relationship name="toFT2" source="FlattenedTest3" target="FlattenedTest2" db-relationship-path="toFT2"/>
-	<obj-relationship name="toFT3" source="FlattenedTest4" target="FlattenedTest3" db-relationship-path="toFT3"/>
-	<obj-relationship name="children" source="Master" target="Child" deleteRule="Deny" db-relationship-path="children"/>
 	<obj-relationship name="toRelationshipHelper" source="MeaningfulFK" target="RelationshipHelper" db-relationship-path="toRelationshipHelper"/>
 	<obj-relationship name="children" source="ReflexiveAndToOne" target="ReflexiveAndToOne" db-relationship-path="children"/>
 	<obj-relationship name="toHelper" source="ReflexiveAndToOne" target="RelationshipHelper" db-relationship-path="toHelper"/>
@@ -365,12 +65,4 @@
 	<obj-relationship name="fksOfDifferentType" source="RelationshipHelper" target="FkOfDifferentType" db-relationship-path="fksOfDifferentType"/>
 	<obj-relationship name="meanigfulFKs" source="RelationshipHelper" target="MeaningfulFK" db-relationship-path="meanigfulFKs"/>
 	<obj-relationship name="reflexiveAndToOneArray" source="RelationshipHelper" target="ReflexiveAndToOne" db-relationship-path="reflexiveAndToOneArray"/>
-	<obj-relationship name="targets" source="SetToMany" target="SetToManyTarget" collection-type="java.util.Set" db-relationship-path="targets"/>
-	<obj-relationship name="setToMany" source="SetToManyTarget" target="SetToMany" db-relationship-path="setToMany"/>
-	<obj-relationship name="root" source="ToManyFkDep" target="ToManyFkRoot" db-relationship-path="root"/>
-	<obj-relationship name="root2" source="ToManyFkDep" target="ToManyRoot2" db-relationship-path="root2"/>
-	<obj-relationship name="deps" source="ToManyFkRoot" target="ToManyFkDep" db-relationship-path="deps"/>
-	<obj-relationship name="deps" source="ToManyRoot2" target="ToManyFkDep" db-relationship-path="deps"/>
-	<obj-relationship name="toPK" source="ToOneFK1" target="ToOneFK2" db-relationship-path="toPK"/>
-	<obj-relationship name="toOneToFK" source="ToOneFK2" target="ToOneFK1" db-relationship-path="toOneToFK"/>
 </data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/d7178a8b/cayenne-server/src/test/resources/relationships1.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/relationships1.map.xml b/cayenne-server/src/test/resources/relationships1.map.xml
deleted file mode 100644
index 4ca763d..0000000
--- a/cayenne-server/src/test/resources/relationships1.map.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
-	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
-	 project-version="7">
-	<property name="defaultPackage" value="org.apache.cayenne.testdo.r1"/>
-	<db-entity name="ACTIVITY">
-		<db-attribute name="ACTIVITY_ID" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
-		<db-attribute name="APPOINT_DATE" type="DATE" isMandatory="true"/>
-		<db-attribute name="APPOINT_NO" type="INTEGER" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="RESULT">
-		<db-attribute name="APPOINT_DATE" type="DATE" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="APPOINT_NO" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="RESULTNAME" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
-	</db-entity>
-	<obj-entity name="Activity" className="org.apache.cayenne.testdo.r1.Activity" dbEntityName="ACTIVITY">
-		<obj-attribute name="appointmentDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
-		<obj-attribute name="appointmentNo" type="int" db-attribute-path="APPOINT_NO"/>
-	</obj-entity>
-	<obj-entity name="ActivityResult" className="org.apache.cayenne.testdo.r1.ActivityResult" dbEntityName="RESULT">
-		<obj-attribute name="appointDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
-		<obj-attribute name="appointNo" type="int" db-attribute-path="APPOINT_NO"/>
-		<obj-attribute name="field" type="java.lang.String" db-attribute-path="RESULTNAME"/>
-	</obj-entity>
-	<db-relationship name="ActivityResultsRel" source="ACTIVITY" target="RESULT" toMany="true">
-		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
-		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
-	</db-relationship>
-	<db-relationship name="ActivitiesRel" source="RESULT" target="ACTIVITY" toMany="true">
-		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
-		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
-	</db-relationship>
-	<obj-relationship name="results" source="Activity" target="ActivityResult" collection-type="java.util.Map" map-key="field" deleteRule="Deny" db-relationship-path="ActivityResultsRel"/>
-</data-map>