cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r951757 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/ java/org/apache/cayenne/testdo/inheritance/vertical/ java/org/apache/cayenne/testdo/inheritance/vertical/auto/ resources/
Date Sat, 05 Jun 2010 19:57:29 GMT
Author: aadamchik
Date: Sat Jun  5 19:57:28 2010
New Revision: 951757

URL: http://svn.apache.org/viewvc?rev=951757&view=rev
Log:
CAY-1090 vertical inheritance

* unit tests for attribute overrides

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Root.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Sub1.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Root.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Sub1.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/inheritance-vertical.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java?rev=951757&r1=951756&r2=951757&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
Sat Jun  5 19:57:28 2010
@@ -26,6 +26,8 @@ import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.test.DBHelper;
 import org.apache.cayenne.test.TableHelper;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv1Root;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv1Sub1;
 import org.apache.cayenne.testdo.inheritance.vertical.IvRoot;
 import org.apache.cayenne.testdo.inheritance.vertical.IvSub1;
 import org.apache.cayenne.testdo.inheritance.vertical.IvSub1Sub1;
@@ -45,6 +47,9 @@ public class VerticalInheritanceTest ext
         dbHelper.deleteAll("IV_SUB1");
         dbHelper.deleteAll("IV_SUB2");
         dbHelper.deleteAll("IV_ROOT");
+        
+        dbHelper.deleteAll("IV1_SUB1");
+        dbHelper.deleteAll("IV1_ROOT");
     }
 
     @Override
@@ -385,4 +390,43 @@ public class VerticalInheritanceTest ext
         assertEquals(2, results.size());
     }
 
+    public void testSelectQuery_AttributeOverrides() throws Exception {
+        DBHelper dbHelper = getDbHelper();
+
+        TableHelper iv1RootTable = new TableHelper(dbHelper, "IV1_ROOT");
+        iv1RootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
+
+        TableHelper iv1Sub1Table = new TableHelper(dbHelper, "IV1_SUB1");
+        iv1Sub1Table.setColumns("ID", "SUB1_NAME");
+
+        // insert
+        iv1RootTable.insert(1, "xROOT", null);
+        iv1RootTable.insert(2, "xSUB1_ROOT", "Iv1Sub1");
+        iv1Sub1Table.insert(2, "xSUB1");
+
+        SelectQuery query = new SelectQuery(Iv1Root.class);
+        List<Iv1Root> results = createDataContext().performQuery(query);
+
+        assertEquals(2, results.size());
+
+        // since we don't have ordering, need to analyze results in an order agnostic
+        // fashion
+        Map<String, Iv1Root> resultTypes = new HashMap<String, Iv1Root>();
+
+        for (Iv1Root result : results) {
+            resultTypes.put(result.getClass().getName(), result);
+        }
+
+        assertEquals(2, resultTypes.size());
+
+        Iv1Root root = resultTypes.get(Iv1Root.class.getName());
+        assertNotNull(root);
+        assertEquals("xROOT", root.getName());
+        assertNull(root.getDiscriminator());
+
+        Iv1Sub1 sub1 = (Iv1Sub1) resultTypes.get(Iv1Sub1.class.getName());
+        assertNotNull(sub1);
+        assertEquals("xSUB1", sub1.getName());
+    }
+
 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Root.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Root.java?rev=951757&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Root.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Root.java
Sat Jun  5 19:57:28 2010
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.inheritance.vertical;
+
+import org.apache.cayenne.testdo.inheritance.vertical.auto._Iv1Root;
+
+public class Iv1Root extends _Iv1Root {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Sub1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Sub1.java?rev=951757&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Sub1.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/Iv1Sub1.java
Sat Jun  5 19:57:28 2010
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.inheritance.vertical;
+
+import org.apache.cayenne.testdo.inheritance.vertical.auto._Iv1Sub1;
+
+public class Iv1Sub1 extends _Iv1Sub1 {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Root.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Root.java?rev=951757&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Root.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Root.java
Sat Jun  5 19:57:28 2010
@@ -0,0 +1,32 @@
+package org.apache.cayenne.testdo.inheritance.vertical.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+
+/**
+ * Class _Iv1Root 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 _Iv1Root extends CayenneDataObject {
+
+    public static final String DISCRIMINATOR_PROPERTY = "discriminator";
+    public static final String NAME_PROPERTY = "name";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public void setDiscriminator(String discriminator) {
+        writeProperty("discriminator", discriminator);
+    }
+    public String getDiscriminator() {
+        return (String)readProperty("discriminator");
+    }
+
+    public void setName(String name) {
+        writeProperty("name", name);
+    }
+    public String getName() {
+        return (String)readProperty("name");
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Sub1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Sub1.java?rev=951757&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Sub1.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/inheritance/vertical/auto/_Iv1Sub1.java
Sat Jun  5 19:57:28 2010
@@ -0,0 +1,24 @@
+package org.apache.cayenne.testdo.inheritance.vertical.auto;
+
+import org.apache.cayenne.testdo.inheritance.vertical.Iv1Root;
+
+/**
+ * Class _Iv1Sub1 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 _Iv1Sub1 extends Iv1Root {
+
+    public static final String NAME_PROPERTY = "name";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public void setName(String name) {
+        writeProperty("name", name);
+    }
+    public String getName() {
+        return (String)readProperty("name");
+    }
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/inheritance-vertical.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/inheritance-vertical.map.xml?rev=951757&r1=951756&r2=951757&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/inheritance-vertical.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/inheritance-vertical.map.xml
Sat Jun  5 19:57:28 2010
@@ -4,6 +4,15 @@
 	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
 	 project-version="6">
 	<property name="defaultPackage" value="org.apache.cayenne.testdo.inheritance.vertical"/>
+	<db-entity name="IV1_ROOT">
+		<db-attribute name="DISCRIMINATOR" type="VARCHAR" length="10"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<db-entity name="IV1_SUB1">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="SUB1_NAME" type="VARCHAR" length="100"/>
+	</db-entity>
 	<db-entity name="IV_ROOT">
 		<db-attribute name="DISCRIMINATOR" type="VARCHAR" length="10"/>
 		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
@@ -22,6 +31,15 @@
 		<db-attribute name="NAME" type="VARCHAR" length="100"/>
 		<db-attribute name="SUB2_NAME" type="VARCHAR" length="100"/>
 	</db-entity>
+	<obj-entity name="Iv1Root" className="org.apache.cayenne.testdo.inheritance.vertical.Iv1Root"
dbEntityName="IV1_ROOT">
+		<obj-attribute name="discriminator" type="java.lang.String" db-attribute-path="DISCRIMINATOR"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="Iv1Sub1" superEntityName="Iv1Root" className="org.apache.cayenne.testdo.inheritance.vertical.Iv1Sub1">
+		<qualifier><![CDATA[discriminator = "Iv1Sub1"]]></qualifier>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="sub1.SUB1_NAME"/>
+		<attribute-override name="name" db-attribute-path="sub1.SUB1_NAME"/>
+	</obj-entity>
 	<obj-entity name="IvRoot" className="org.apache.cayenne.testdo.inheritance.vertical.IvRoot"
dbEntityName="IV_ROOT">
 		<obj-attribute name="discriminator" type="java.lang.String" db-attribute-path="DISCRIMINATOR"/>
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
@@ -41,6 +59,12 @@
 		<qualifier><![CDATA[discriminator = "IvSub2"]]></qualifier>
 		<obj-attribute name="sub2Name" type="java.lang.String" db-attribute-path="sub2.SUB2_NAME"/>
 	</obj-entity>
+	<db-relationship name="sub1" source="IV1_ROOT" target="IV1_SUB1" toDependentPK="true"
toMany="false">
+		<db-attribute-pair source="ID" target="ID"/>
+	</db-relationship>
+	<db-relationship name="root" source="IV1_SUB1" target="IV1_ROOT" toMany="false">
+		<db-attribute-pair source="ID" target="ID"/>
+	</db-relationship>
 	<db-relationship name="sub1" source="IV_ROOT" target="IV_SUB1" toDependentPK="true" toMany="false">
 		<db-attribute-pair source="ID" target="ID"/>
 	</db-relationship>



Mime
View raw message