cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r723345 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java
Date Thu, 04 Dec 2008 15:16:36 GMT
Author: aadamchik
Date: Thu Dec  4 07:16:36 2008
New Revision: 723345

URL: http://svn.apache.org/viewvc?rev=723345&view=rev
Log:
extra unit tests for sanity sake; no real bugs discovered

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java?rev=723345&r1=723344&r2=723345&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SingleTableInheritanceTest.java
Thu Dec  4 07:16:36 2008
@@ -20,6 +20,7 @@
 
 import java.util.List;
 
+import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.QueryChain;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
@@ -35,6 +36,49 @@
         super.setUp();
         deleteTestData();
     }
+    
+    public void testMatchingOnSuperAttributes() {
+        QueryChain insert = new QueryChain();
+        insert
+                .addQuery(new SQLTemplate(
+                        AbstractPerson.class,
+                        "INSERT INTO PERSON (PERSON_ID, NAME, PERSON_TYPE) VALUES (1, 'E1',
'EE')"));
+        insert
+                .addQuery(new SQLTemplate(
+                        AbstractPerson.class,
+                        "INSERT INTO PERSON (PERSON_ID, NAME, PERSON_TYPE) VALUES (2, 'E2',
'EM')"));
+        createDataContext().performGenericQuery(insert);
+        
+        // fetch on leaf, but match on a super attribute
+        SelectQuery select = new SelectQuery(Manager.class);
+        select.andQualifier(ExpressionFactory.matchExp(AbstractPerson.NAME_PROPERTY, "E2"));
+    
+        List<Manager> results = createDataContext().performQuery(select);
+        assertEquals(1, results.size());
+        assertEquals("E2", results.get(0).getName());
+    }
+    
+    public void testMatchingOnSuperAttributesWithPrefetch() {
+        QueryChain insert = new QueryChain();
+        insert
+                .addQuery(new SQLTemplate(
+                        AbstractPerson.class,
+                        "INSERT INTO PERSON (PERSON_ID, NAME, PERSON_TYPE) VALUES (1, 'E1',
'EE')"));
+        insert
+                .addQuery(new SQLTemplate(
+                        AbstractPerson.class,
+                        "INSERT INTO PERSON (PERSON_ID, NAME, PERSON_TYPE) VALUES (2, 'E2',
'EM')"));
+        createDataContext().performGenericQuery(insert);
+        
+        // fetch on leaf, but match on a super attribute
+        SelectQuery select = new SelectQuery(Employee.class);
+        select.addPrefetch(Employee.TO_DEPARTMENT_PROPERTY);
+        select.andQualifier(ExpressionFactory.matchExp(AbstractPerson.NAME_PROPERTY, "E2"));
+    
+        List<Manager> results = createDataContext().performQuery(select);
+        assertEquals(1, results.size());
+        assertEquals("E2", results.get(0).getName());
+    }
 
     public void testPaginatedQueries() {
 



Mime
View raw message