cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r423642 - in /incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src: cayenne/java/org/objectstyle/cayenne/query/ tests/java/org/objectstyle/cayenne/access/ tests/java/org/objectstyle/cayenne/query/
Date Wed, 19 Jul 2006 22:37:19 GMT
Author: aadamchik
Date: Wed Jul 19 15:37:18 2006
New Revision: 423642

URL: http://svn.apache.org/viewvc?rev=423642&view=rev
Log:
CAY-603

Added:
    incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextQueryChainTst.java
    incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/query/QueryChainTst.java
Modified:
    incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/query/QueryChain.java

Modified: incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/query/QueryChain.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/query/QueryChain.java?rev=423642&r1=423641&r2=423642&view=diff
==============================================================================
--- incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/query/QueryChain.java
(original)
+++ incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/query/QueryChain.java
Wed Jul 19 15:37:18 2006
@@ -64,7 +64,9 @@
 import org.objectstyle.cayenne.map.EntityResolver;
 
 /**
- * A Query decorator for a collection of other queries.
+ * A Query decorator for a collection of other queries. Note that QueryChain will always
+ * return DataRows (that is if it returns data), as it has no way of knowing how to
+ * convert the results to objects.
  * 
  * @since 1.2
  * @author Andrus Adamchik
@@ -156,7 +158,9 @@
      * Returns default metadata.
      */
     public QueryMetadata getMetaData(EntityResolver resolver) {
-        return DefaultQueryMetadata.defaultMetadata;
+        QueryMetadataWrapper wrapper = new QueryMetadataWrapper(DefaultQueryMetadata.defaultMetadata);
+        wrapper.override(QueryMetadata.FETCHING_DATA_ROWS_PROPERTY, Boolean.TRUE);
+        return wrapper;
     }
 
     /**

Added: incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextQueryChainTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextQueryChainTst.java?rev=423642&view=auto
==============================================================================
--- incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextQueryChainTst.java
(added)
+++ incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextQueryChainTst.java
Wed Jul 19 15:37:18 2006
@@ -0,0 +1,92 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.access;
+
+import java.util.List;
+
+import org.objectstyle.art.Artist;
+import org.objectstyle.cayenne.DataRow;
+import org.objectstyle.cayenne.QueryResponse;
+import org.objectstyle.cayenne.query.QueryChain;
+import org.objectstyle.cayenne.query.SelectQuery;
+import org.objectstyle.cayenne.unit.CayenneTestCase;
+
+public class DataContextQueryChainTst extends CayenneTestCase {
+
+    public void testSelectQuery() {
+        DataContext context = createDataContext();
+        Artist a1 = (Artist) context.newObject(Artist.class);
+        a1.setArtistName("X");
+        context.commitChanges();
+
+        QueryChain chain = new QueryChain();
+        chain.addQuery(new SelectQuery(Artist.class));
+        chain.addQuery(new SelectQuery(Artist.class));
+
+        QueryResponse r = context.performGenericQuery(chain);
+
+        // data comes back as datarows
+        assertEquals(2, r.size());
+        r.reset();
+        r.next();
+        List l1 = r.currentList();
+        r.next();
+        List l2 = r.currentList();
+        
+        assertTrue(l1.get(0) instanceof DataRow);
+        assertTrue(l2.get(0) instanceof DataRow);
+    }
+}

Added: incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/query/QueryChainTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/query/QueryChainTst.java?rev=423642&view=auto
==============================================================================
--- incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/query/QueryChainTst.java
(added)
+++ incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/query/QueryChainTst.java
Wed Jul 19 15:37:18 2006
@@ -0,0 +1,93 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.query;
+
+import org.objectstyle.art.Artist;
+import org.objectstyle.cayenne.unit.CayenneTestCase;
+
+public class QueryChainTst extends CayenneTestCase {
+
+    public void testSelectQuery() {
+
+        QueryChain chain = new QueryChain();
+        chain.addQuery(new SelectQuery(Artist.class));
+        chain.addQuery(new SelectQuery(Artist.class));
+
+        QueryMetadata md = chain.getMetaData(getDomain().getEntityResolver());
+
+        assertNotNull(md);
+        assertTrue(md.isFetchingDataRows());
+        assertNull(md.getObjEntity());
+    }
+
+    public void testSelectQueryDataRows() {
+
+        QueryChain chain = new QueryChain();
+        SelectQuery q1 = new SelectQuery(Artist.class);
+        q1.setFetchingDataRows(true);
+        chain.addQuery(q1);
+        
+        SelectQuery q2 = new SelectQuery(Artist.class);
+        q2.setFetchingDataRows(true);
+        chain.addQuery(q2);
+
+        QueryMetadata md = chain.getMetaData(getDomain().getEntityResolver());
+
+        assertNotNull(md);
+        assertTrue(md.isFetchingDataRows());
+        assertNull(md.getObjEntity());
+    }
+}



Mime
View raw message