cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1153427 - in /cayenne/main/branches/STABLE-3.0: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/
Date Wed, 03 Aug 2011 11:14:08 GMT
Author: dkazimirchyk
Date: Wed Aug  3 11:14:06 2011
New Revision: 1153427

URL: http://svn.apache.org/viewvc?rev=1153427&view=rev
Log:
CAY-1585 SelectQuery automatic cache key needs FetchOffset

applying fix to 3.0 branch

Modified:
    cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java

Modified: cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt Wed Aug
 3 11:14:06 2011
@@ -23,6 +23,7 @@ CAY-1514 ClassCastException when EJQLQue
 CAY-1577 SQL queries for LIKE expressions with escape character generated with syntax errors
 CAY-1581 Not-Escaping <> during serialization to *.map.xml
 CAY-1583 context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
+CAY-1585 SelectQuery automatic cache key needs FetchOffset
 
 ----------------------------------
 Release: 3.0.2

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
Wed Aug  3 11:14:06 2011
@@ -84,6 +84,16 @@ class EJBQLQueryMetadata extends BaseQue
                                 positionalParameters.get(parameterKey));
                     }
                 }
+                
+                if (query.getFetchOffset() > 0 || query.getFetchLimit() > 0) {
+                    key.append('/');
+                    if (query.getFetchOffset() > 0) {
+                        key.append('o').append(query.getFetchOffset());
+                    }
+                    if (query.getFetchLimit() > 0) {
+                        key.append('l').append(query.getFetchLimit());
+                    }
+                }
 
                 this.cacheKey = key.toString();
             }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
Wed Aug  3 11:14:06 2011
@@ -89,6 +89,16 @@ class ProcedureQueryMetadata extends Bas
                                 parameters.get(parameterKey));
                     }
                 }
+                
+                if (query.getFetchOffset() > 0 || query.getFetchLimit() > 0) {
+                    key.append('/');
+                    if (query.getFetchOffset() > 0) {
+                        key.append('o').append(query.getFetchOffset());
+                    }
+                    if (query.getFetchLimit() > 0) {
+                        key.append('l').append(query.getFetchLimit());
+                    }
+                }
 
                 this.cacheKey = key.toString();
             }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
Wed Aug  3 11:14:06 2011
@@ -71,6 +71,16 @@ class SQLTemplateMetadata extends BaseQu
                                 parameters.get(parameterKey));
                     }
                 }
+                
+                if (query.getFetchOffset() > 0 || query.getFetchLimit() > 0) {
+                    key.append('/');
+                    if (query.getFetchOffset() > 0) {
+                        key.append('o').append(query.getFetchOffset());
+                    }
+                    if (query.getFetchLimit() > 0) {
+                        key.append('l').append(query.getFetchLimit());
+                    }
+                }
 
                 this.cacheKey = key.toString();
             }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
Wed Aug  3 11:14:06 2011
@@ -78,10 +78,16 @@ class SelectQueryMetadata extends BaseQu
                     }
                 }
 
-                if (query.getFetchLimit() > 0) {
-                    key.append('/').append(query.getFetchLimit());
+                if (query.getFetchOffset() > 0 || query.getFetchLimit() > 0) {
+                    key.append('/');
+                    if (query.getFetchOffset() > 0) {
+                        key.append('o').append(query.getFetchOffset());
+                    }
+                    if (query.getFetchLimit() > 0) {
+                        key.append('l').append(query.getFetchLimit());
+                    }
                 }
-
+                
                 this.cacheKey = key.toString();
             }
 

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
Wed Aug  3 11:14:06 2011
@@ -56,12 +56,16 @@ public class EJBQLQueryTest extends Caye
         EJBQLQuery q1 = new EJBQLQuery(ejbql1);
         q1.setParameter(1, "X");
         q1.setParameter("name", "Y");
+        q1.setFetchOffset(1);
+        q1.setFetchLimit(5);
         q1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
         String ejbql2 = "select a FROM Artist a WHERE a.artistName = ?1 OR a.artistName =
:name";
         EJBQLQuery q2 = new EJBQLQuery(ejbql2);
         q2.setParameter(1, "X");
         q2.setParameter("name", "Y");
+        q2.setFetchOffset(1);
+        q2.setFetchLimit(5);
         q2.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
         EntityResolver resolver = getDomain().getEntityResolver();

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
Wed Aug  3 11:14:06 2011
@@ -80,4 +80,21 @@ public class ProcedureQueryCacheKeyTest 
         assertEquals("proc:", md1.getCacheKey());
     }
 
+    public void testCacheFetchOffsetAndLimit() {
+        EntityResolver resolver = getDomain().getEntityResolver();
+        
+        ProcedureQuery q1 = new ProcedureQuery("ABC", Artist.class);
+        q1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        q1.setFetchOffset(5);
+        q1.setFetchLimit(3);
+        
+        ProcedureQuery q2 = new ProcedureQuery("ABC", Artist.class);
+        q2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        q2.setFetchOffset(5);
+        q2.setFetchLimit(3);
+        
+        assertEquals(q1.getMetaData(resolver).getCacheKey(), q2
+                .getMetaData(resolver)
+                .getCacheKey());
+    }
 }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
Wed Aug  3 11:14:06 2011
@@ -80,4 +80,21 @@ public class SQLTemplateCacheKeyTest ext
         assertFalse("XYZ".equals(md1.getCacheKey()));
     }
 
+    public void testCacheFetchLimitAndOffset() {
+        EntityResolver resolver = getDomain().getEntityResolver();
+        
+        SQLTemplate q1 = new SQLTemplate(Artist.class, "SELECT ME");
+        q1.setFetchOffset(5);
+        q1.setFetchLimit(10);
+        q1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        
+        SQLTemplate q2 = new SQLTemplate(Artist.class, "SELECT ME");
+        q2.setFetchOffset(5);
+        q2.setFetchLimit(10);
+        q2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+
+        assertEquals(q1.getMetaData(resolver).getCacheKey(), q2
+                .getMetaData(resolver)
+                .getCacheKey());
+    }
 }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java?rev=1153427&r1=1153426&r2=1153427&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
Wed Aug  3 11:14:06 2011
@@ -602,4 +602,29 @@ public class SelectQueryTest extends Sel
         query.addPrefetch("toGallery");
         createDataContext().performQuery(query);
     }
+    
+    public void testCacheOffsetAndLimit() {
+        ObjectContext context = createDataContext();
+        
+        SelectQuery query1 = new SelectQuery(Artist.class);
+        query1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        query1.setFetchOffset(0);
+        query1.setFetchLimit(10);
+        context.performQuery(query1);
+
+        SelectQuery query2 = new SelectQuery(Artist.class);
+        query2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        query2.setFetchOffset(10);
+        query2.setFetchLimit(10);
+        context.performQuery(query2);
+
+        SelectQuery query3 = new SelectQuery(Artist.class);
+        query3.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        query3.setFetchOffset(10);
+        query3.setFetchLimit(10);
+        context.performQuery(query3);
+
+        assertFalse(query1.metaData.getCacheKey().equals(query2.metaData.cacheKey));
+        assertEquals(query2.metaData.getCacheKey(), query3.metaData.getCacheKey());
+    }
 }



Mime
View raw message