You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by an...@apache.org on 2010/03/11 10:36:36 UTC

svn commit: r921754 - in /cayenne/sandbox/cayenne-gwt: ./ src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/ src/main/resources/org/apache/cayenne/query/emul/org/apache/cay...

Author: andrey
Date: Thu Mar 11 09:36:35 2010
New Revision: 921754

URL: http://svn.apache.org/viewvc?rev=921754&view=rev
Log:
RefreshQuery, ObjectIdQuery, RelationshipQuery support

Added:
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/IndirectQuery.java
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/NamedQuery.java
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/ObjectIdQuery.java
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RefreshQuery.java
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RelationshipQuery.java
Modified:
    cayenne/sandbox/cayenne-gwt/pom.xml
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ObjectId.java
    cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/Util.java
    cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/CayenneGWTTest.java
    cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/GwtTestQuery.java
    cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/model/auto/_TestDomainMap.java
    cayenne/sandbox/cayenne-gwt/src/test/resources/TestDomainMap.map.xml

Modified: cayenne/sandbox/cayenne-gwt/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/pom.xml?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/pom.xml (original)
+++ cayenne/sandbox/cayenne-gwt/pom.xml Thu Mar 11 09:36:35 2010
@@ -41,7 +41,7 @@
   	<dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.1</version>
+      <version>4.8.1</version>
       <scope>test</scope>
     </dependency>
   	<dependency>

Modified: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ObjectId.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ObjectId.java?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ObjectId.java (original)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/ObjectId.java Thu Mar 11 09:36:35 2010
@@ -26,7 +26,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.util.IDUtil;
+import org.apache.cayenne.util.Util;
 
 /**
  * A portable global identifier for persistent objects. ObjectId can be temporary (used
@@ -256,4 +258,57 @@ public class ObjectId<T> implements Seri
 
         return o1.equals(o2);
     }
+    
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+
+        if (!(object instanceof ObjectId)) {
+            return false;
+        }
+
+        ObjectId id = (ObjectId) object;
+
+        if (!Util.nullSafeEquals(entityName, id.entityName)) {
+            return false;
+        }
+
+        if (isTemporary()) {
+            key.equals(id.key);
+        }
+
+        if (singleKey != null) {
+            return Util.nullSafeEquals(singleKey, id.singleKey)
+                    && valueEquals(singleValue, id.singleValue);
+        }
+
+        if (id.objectIdKeys == null) {
+            return objectIdKeys == null;
+        }
+
+        if (id.objectIdKeys.size() != objectIdKeys.size()) {
+            return false;
+        }
+
+        for (Map.Entry<String, ?> entry : objectIdKeys.entrySet()) {
+            Object entryKey = entry.getKey();
+            Object entryValue = entry.getValue();
+
+            if (entryValue == null) {
+                if (id.objectIdKeys.get(entryKey) != null
+                        || !id.objectIdKeys.containsKey(entryKey)) {
+                    return false;
+                }
+            }
+            else {
+                if (!valueEquals(entryValue, id.objectIdKeys.get(entryKey))) {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
 }

Modified: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/Util.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/Util.java?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/Util.java (original)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/emul/org/apache/cayenne/util/Util.java Thu Mar 11 09:36:35 2010
@@ -19,6 +19,9 @@
 
 package org.apache.cayenne.util;
 
+import java.util.HashMap;
+import java.util.Map;
+
 
 /**
  * Contains various unorganized static utility methods used across Cayenne.
@@ -68,4 +71,30 @@ public class Util {
         return string == null || string.length() == 0;
     }
 
+    /**
+     * Creates a mutable map out of two arrays with keys and values.
+     * 
+     * @since 1.2
+     */
+    public static <K, V> Map<K, V> toMap(K[] keys, V[] values) {
+        int keysSize = (keys != null) ? keys.length : 0;
+        int valuesSize = (values != null) ? values.length : 0;
+
+        if (keysSize == 0 && valuesSize == 0) {
+            // return mutable map
+            return new HashMap<K, V>();
+        }
+
+        if (keysSize != valuesSize) {
+            throw new IllegalArgumentException(
+                    "The number of keys doesn't match the number of values.");
+        }
+
+        Map<K, V> map = new HashMap<K, V>();
+        for (int i = 0; i < keysSize; i++) {
+            map.put(keys[i], values[i]);
+        }
+
+        return map;
+    }
 }

Added: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/IndirectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/IndirectQuery.java?rev=921754&view=auto
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/IndirectQuery.java (added)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/IndirectQuery.java Thu Mar 11 09:36:35 2010
@@ -0,0 +1,41 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.query;
+
+
+/**
+ * A convenience superclass of the queries that resolve into some other queries during the
+ * routing phase. Provides caching of a replacement query.
+ * 
+ * @since 1.2
+ */
+public abstract class IndirectQuery implements Query {
+
+    protected String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

Added: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/NamedQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/NamedQuery.java?rev=921754&view=auto
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/NamedQuery.java (added)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/NamedQuery.java Thu Mar 11 09:36:35 2010
@@ -0,0 +1,86 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.query;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cayenne.util.Util;
+
+/**
+ * A query that is a reference to a named parameterized query stored in the mapping. The
+ * actual query is resolved during execution.
+ * 
+ * @since 1.2
+ */
+public class NamedQuery extends IndirectQuery {
+
+    protected Map<String, Object> parameters;
+
+    protected boolean forceNoCache;
+
+    protected BaseQueryMetadata overrideMetadata;
+    
+    private NamedQuery() {}
+
+    public NamedQuery(String name) {
+        this(name, null);
+    }
+
+    public NamedQuery(String name, Map<String, ?> parameters) {
+        this.name = name;
+
+        // copy parameters map (among other things to make hessian serialization work).
+        if (parameters != null && !parameters.isEmpty()) {
+            this.parameters = new HashMap<String, Object>(parameters);
+        }
+    }
+
+    /**
+     * Creates NamedQuery with parameters passed as two matching arrays of keys and
+     * values.
+     */
+    public NamedQuery(String name, String[] keys, Object[] values) {
+        this.name = name;
+        this.parameters = Util.toMap(keys, values);
+    }
+
+    /**
+     * Initializes metadata overrides. Needed to store the metadata for the remote query
+     * proxies that have no access to the actual query.
+     */
+    public void initMetadata(QueryMetadata metadata) {
+        if (metadata != null) {
+            this.overrideMetadata = new BaseQueryMetadata();
+            this.overrideMetadata.copyFromInfo(metadata);
+        }
+        else {
+            this.overrideMetadata = null;
+        }
+    }
+
+    public boolean isForceNoCache() {
+        return forceNoCache;
+    }
+
+    public void setForceNoCache(boolean forcingNoCache) {
+        this.forceNoCache = forcingNoCache;
+    }
+}

Added: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/ObjectIdQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/ObjectIdQuery.java?rev=921754&view=auto
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/ObjectIdQuery.java (added)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/ObjectIdQuery.java Thu Mar 11 09:36:35 2010
@@ -0,0 +1,119 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.query;
+
+import java.io.Serializable;
+
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.util.Util;
+
+/**
+ * A query that matches zero or one object or data row corresponding to the ObjectId. Used
+ * internally by Cayenne to lookup objects by id. Notice that cache policies of
+ * ObjectIdQuery are different from generic {@link QueryMetadata} cache policies.
+ * ObjectIdQuery is special - it is the only query that can be done against Cayenne main
+ * cache, thus cache handling is significantly different from all other of the queries.
+ * 
+ * @since 1.2
+ */
+public class ObjectIdQuery extends IndirectQuery {
+
+    // TODO: Andrus, 2/18/2006 - reconcile this with QueryMetadata cache policies
+    public static final int CACHE = 1;
+    public static final int CACHE_REFRESH = 2;
+    public static final int CACHE_NOREFRESH = 3;
+
+    protected ObjectId<Serializable> objectId;
+    protected int cachePolicy;
+    protected boolean fetchingDataRows;
+
+    // needed for hessian serialization
+    @SuppressWarnings("unused")
+    private ObjectIdQuery() {
+        this.cachePolicy = CACHE_REFRESH;
+    }
+
+    /**
+     * Creates a refreshing SingleObjectQuery.
+     */
+    public ObjectIdQuery(ObjectId objectID) {
+        this(objectID, false, CACHE_REFRESH);
+    }
+
+    /**
+     * Creates a new ObjectIdQuery.
+     */
+    public ObjectIdQuery(ObjectId objectId, boolean fetchingDataRows, int cachePolicy) {
+        if (objectId == null) {
+            throw new NullPointerException("Null objectID");
+        }
+
+        this.objectId = objectId;
+        this.cachePolicy = cachePolicy;
+        this.fetchingDataRows = fetchingDataRows;
+    }
+
+    public ObjectId getObjectId() {
+        return objectId;
+    }
+
+    public int getCachePolicy() {
+        return cachePolicy;
+    }
+
+    public boolean isFetchMandatory() {
+        return cachePolicy == CACHE_REFRESH;
+    }
+
+    public boolean isFetchAllowed() {
+        return cachePolicy != CACHE_NOREFRESH;
+    }
+
+    public boolean isFetchingDataRows() {
+        return fetchingDataRows;
+    }
+
+    /**
+     * An object is considered equal to this query if it is also a ObjectIdQuery with
+     * an equal ObjectId.
+     */
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+
+        if (!(object instanceof ObjectIdQuery)) {
+            return false;
+        }
+
+        ObjectIdQuery query = (ObjectIdQuery) object;
+
+        return Util.nullSafeEquals(objectId, query.getObjectId());
+    }
+
+    /**
+     * Implements a standard hashCode contract considering custom 'equals' implementation.
+     */
+    @Override
+    public int hashCode() {
+        return (objectId != null) ? objectId.hashCode() : 11;
+    }
+}

Added: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RefreshQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RefreshQuery.java?rev=921754&view=auto
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RefreshQuery.java (added)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RefreshQuery.java Thu Mar 11 09:36:35 2010
@@ -0,0 +1,92 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.query;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.cayenne.Persistent;
+
+/**
+ * A query that allows to explicitly clear both object and list caches either via refetch
+ * (eager refresh) or invalidate (lazy refresh).
+ * 
+ * @since 3.0
+ */
+public class RefreshQuery implements Query {
+
+    protected Collection<?> objects;
+    protected Query query;
+    protected String[] groupKeys;
+
+    /**
+     * Creates a RefreshQuery that does full refresh of all registered objects, cascading
+     * refresh all the way to the shared cache.
+     */
+    public RefreshQuery() {
+
+    }
+
+    /**
+     * Creates a RefreshQuery that refreshes a collection of objects, including
+     * invalidation of their relationships.
+     */
+    public RefreshQuery(Collection<?> objects) {
+        this.objects = objects;
+    }
+
+    /**
+     * Creates a RefreshQuery that refreshes a single object, including invalidation of
+     * its relationships.
+     */
+    public RefreshQuery(Persistent object) {
+        this(Arrays.asList(object));
+    }
+
+    /**
+     * Creates a RefreshQuery that refreshes results of a query and individual objects in
+     * the result.
+     */
+    public RefreshQuery(Query query) {
+        this.query = query;
+    }
+
+    /**
+     * Creates a RefreshQuery that refreshes query results identified by group keys.
+     */
+    public RefreshQuery(String... groupKeys) {
+        this.groupKeys = groupKeys;
+    }
+
+    public String getName() {
+        return null;
+    }
+
+    public boolean isRefreshAll() {
+        return objects == null && query == null && groupKeys == null;
+    }
+
+    public String[] getGroupKeys() {
+        return groupKeys;
+    }
+
+    public Collection<?> getObjects() {
+        return objects;
+    }
+}

Added: cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RelationshipQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RelationshipQuery.java?rev=921754&view=auto
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RelationshipQuery.java (added)
+++ cayenne/sandbox/cayenne-gwt/src/main/resources/org/apache/cayenne/query/emul/org/apache/cayenne/query/RelationshipQuery.java Thu Mar 11 09:36:35 2010
@@ -0,0 +1,105 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.query;
+
+import java.io.Serializable;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.ObjectId;
+
+/**
+ * A query that selects objects related to a given object via a mapped relationship.
+ * RelationshipQuery is used by Cayenne internally to resolve relationships, and is rarely
+ * executed by the application directly, although this of course is possible too.
+ * 
+ * @since 1.2
+ */
+public class RelationshipQuery extends IndirectQuery {
+
+    protected ObjectId<Serializable> objectId;
+    protected String relationshipName;
+    protected boolean refreshing;
+    protected int statementFetchSize;
+
+    // exists for deserialization with Hessian
+    @SuppressWarnings("unused")
+    private RelationshipQuery() {
+
+    }
+
+    /**
+     * Creates a RelationshipQuery. Same as
+     * <em>new RelationshipQuery(objectID, relationshipName, true)</em>.
+     * 
+     * @param objectID ObjectId of a root object of the relationship.
+     * @param relationshipName The name of the relationship.
+     */
+    public RelationshipQuery(ObjectId objectID, String relationshipName) {
+        this(objectID, relationshipName, true);
+    }
+
+    /**
+     * Creates a RelationshipQuery.
+     * 
+     * @param objectID ObjectId of a root object of the relationship.
+     * @param relationshipName The name of the relationship.
+     * @param refreshing whether objects should be refreshed
+     */
+    public RelationshipQuery(ObjectId objectID, String relationshipName,
+            boolean refreshing) {
+        if (objectID == null) {
+            throw new CayenneRuntimeException("Null objectID");
+        }
+
+        this.objectId = objectID;
+        this.relationshipName = relationshipName;
+        this.refreshing = refreshing;
+    }
+
+    public ObjectId getObjectId() {
+        return objectId;
+    }
+
+    public boolean isRefreshing() {
+        return refreshing;
+    }
+
+    public String getRelationshipName() {
+        return relationshipName;
+    }
+
+    /**
+     * Sets statement's fetch size (0 for no default size)
+     * 
+     * @since 3.0
+     */
+    public void setStatementFetchSize(int size) {
+        this.statementFetchSize = size;
+    }
+
+    /**
+     * @return statement's fetch size
+     * @since 3.0
+     */
+    public int getStatementFetchSize() {
+        return statementFetchSize;
+    }
+
+}

Modified: cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/CayenneGWTTest.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/CayenneGWTTest.java?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/CayenneGWTTest.java (original)
+++ cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/CayenneGWTTest.java Thu Mar 11 09:36:35 2010
@@ -19,12 +19,16 @@
 
 package org.apache.cayenne.gwt.test.client;
 
+import org.apache.cayenne.gwt.client.GWTDataContext;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.junit.client.GWTTestCase;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 public abstract class CayenneGWTTest extends GWTTestCase {
 
+	protected GWTDataContext context = GWTDataContext.getInstance();
+	
 	@Override
 	protected void gwtSetUp() throws Exception {
 		TestServiceAsync service = GWT.create(TestService.class);

Modified: cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/GwtTestQuery.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/GwtTestQuery.java?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/GwtTestQuery.java (original)
+++ cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/GwtTestQuery.java Thu Mar 11 09:36:35 2010
@@ -25,9 +25,13 @@ import org.apache.cayenne.DataRow;
 import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.gwt.client.GWTDataContext;
+import org.apache.cayenne.gwt.test.client.model.Forest;
 import org.apache.cayenne.gwt.test.client.model.Tree;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.RefreshQuery;
+import org.apache.cayenne.query.RelationshipQuery;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
@@ -78,7 +82,7 @@ public class GwtTestQuery extends Cayenn
 	}
 	
 	void testQuery(Query query, final TestCallback callback) {
-		GWTDataContext.getInstance().performQuery(query, new TestCallback<List<Object>>() {
+		context.performQuery(query, new TestCallback<List<Object>>() {
 			@Override
 			public void onSuccess(List result) {
 				callback.onSuccess(result);
@@ -92,7 +96,7 @@ public class GwtTestQuery extends Cayenn
 	public void testSQLTemplate() {
 		SQLTemplate template = new SQLTemplate("Tree", "DELETE FROM TREE WHERE TREE_ID=#bind($id)");
 		template.setParameters(Collections.singletonMap("id", 0));
-		GWTDataContext.getInstance().performGenericQuery(template, new TestCallback<QueryResponse>() {
+		context.performGenericQuery(template, new TestCallback<QueryResponse>() {
 			@Override
 			public void onSuccess(QueryResponse result) {
 				//mock assert, but at least we check that GenericResponse was tranferred correctly
@@ -120,4 +124,77 @@ public class GwtTestQuery extends Cayenn
 			}
 		});
 	}
+	
+	public void testRefreshQuery() {
+		//TODO make real test case, instead of mock firing of the query
+		context.performGenericQuery(new RefreshQuery(), 
+				new TestCallback<QueryResponse>() {
+					@Override
+					public void onSuccess(QueryResponse result) {
+						finishTest();
+					}
+				});
+		delayTestFinish(500);
+	}
+	
+	public void testObjectIdQuery() {
+		SelectQuery query = new SelectQuery("Tree", ExpressionFactory.matchExp("name", "Pine"));
+		
+		context.performQuery(query, new TestCallback<List<Tree>>() {
+			@Override
+			public void onSuccess(List<Tree> result) {
+				final Tree pine = result.get(0);
+				ObjectIdQuery query = new ObjectIdQuery(pine.getObjectId());
+				
+				GWTDataContext.getInstance().performQuery(query, new TestCallback<List<Tree>>() {
+					@Override
+					public void onSuccess(List<Tree> result) {
+						assertEquals(result.size(), 1);
+						Tree newPine = result.get(0);
+						assertEquals(newPine.getName(), "Pine");
+						assertEquals(newPine.getObjectId(), pine.getObjectId());
+						finishTest();
+					}
+				});
+			}
+		});
+		delayTestFinish(500);
+	}
+	
+	public void testRelationshipQuery() {
+		SelectQuery query = new SelectQuery("Tree", ExpressionFactory.matchExp("name", "Pine"));
+		
+		context.performQuery(query, new TestCallback<List<Tree>>() {
+			@Override
+			public void onSuccess(List<Tree> result) {
+				final Tree pine = result.get(0);
+				RelationshipQuery query = new RelationshipQuery(pine.getObjectId(), "forest");
+				
+				GWTDataContext.getInstance().performQuery(query, new TestCallback<List<Forest>>() {
+					@Override
+					public void onSuccess(List<Forest> result) {
+						assertEquals(result.size(), 1);
+						Forest forest = result.get(0);
+						assertEquals(forest.getName(), "Pine Forest");
+						finishTest();
+					}
+				});
+			}
+		});
+		delayTestFinish(500);
+	}
+	
+// TODO: uncomment once Cayenne version with r921750 is released
+//	public void testNamedQuery() {
+//		NamedQuery query = new NamedQuery("ForestQuery");
+//		
+//		testQuery(query, new TestCallback<List<Forest>>() {
+//			@Override
+//			public void onSuccess(List<Forest> result) {
+//				assertEquals(result.size(), 1);
+//				Forest forest = result.get(0);
+//				assertEquals(forest.getName(), "Pine Forest");
+//			}
+//		});
+//	}
 }

Modified: cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/model/auto/_TestDomainMap.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/model/auto/_TestDomainMap.java?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/model/auto/_TestDomainMap.java (original)
+++ cayenne/sandbox/cayenne-gwt/src/test/java/org/apache/cayenne/gwt/test/client/model/auto/_TestDomainMap.java Thu Mar 11 09:36:35 2010
@@ -1,7 +1,6 @@
 package org.apache.cayenne.gwt.test.client.model.auto;
 
 
-
 /**
  * This class was generated by Cayenne.
  * It is probably a good idea to avoid changing this class manually,
@@ -9,4 +8,6 @@ package org.apache.cayenne.gwt.test.clie
  * If you need to make any customizations, please use subclass.
  */
 public class _TestDomainMap {
+
+    public static final String FOREST_QUERY_QUERYNAME = "ForestQuery";
 }
\ No newline at end of file

Modified: cayenne/sandbox/cayenne-gwt/src/test/resources/TestDomainMap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-gwt/src/test/resources/TestDomainMap.map.xml?rev=921754&r1=921753&r2=921754&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-gwt/src/test/resources/TestDomainMap.map.xml (original)
+++ cayenne/sandbox/cayenne-gwt/src/test/resources/TestDomainMap.map.xml Thu Mar 11 09:36:35 2010
@@ -31,4 +31,6 @@
 	</db-relationship>
 	<obj-relationship name="trees" source="Forest" target="Tree" deleteRule="Deny" db-relationship-path="trees"/>
 	<obj-relationship name="forest" source="Tree" target="Forest" deleteRule="Nullify" db-relationship-path="forest"/>
+	<query name="ForestQuery" factory="org.apache.cayenne.map.SelectQueryBuilder" root="obj-entity" root-name="Forest">
+	</query>
 </data-map>