cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1143744 - in /cayenne/main/trunk: 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 Thu, 07 Jul 2011 10:04:11 GMT
Author: dkazimirchyk
Date: Thu Jul  7 10:04:11 2011
New Revision: 1143744

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

added fetch offset and limit to cache keys

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

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Jul  7 10:04:11 2011
@@ -32,6 +32,7 @@ CAY-1555 Unpublished dependencies of Mav
 CAY-1575 Error generating Embeddable classes in Cayenne Modeler
 CAY-1577 SQL queries for LIKE expressions with escape character generated with syntax errors
 CAY-1581 Not-Escaping <> during serialization to *.map.xml
+CAY-1585 SelectQuery automatic cache key needs FetchOffset
 
 ----------------------------------
 Release: 3.1 M2

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
Thu Jul  7 10:04:11 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/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java
Thu Jul  7 10:04:11 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/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
Thu Jul  7 10:04:11 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/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
Thu Jul  7 10:04:11 2011
@@ -49,7 +49,7 @@ class SelectQueryMetadata extends BaseQu
             }
             else {
                 // create a unique key based on entity, qualifier, ordering and fetch
-                // limit
+                // offset and limit
 
                 StringBuilder key = new StringBuilder();
 
@@ -77,11 +77,17 @@ 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/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
Thu Jul  7 10:04:11 2011
@@ -105,12 +105,16 @@ public class EJBQLQueryTest extends Serv
         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 = runtime.getDataDomain().getEntityResolver();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryCacheKeyTest.java
Thu Jul  7 10:04:11 2011
@@ -87,4 +87,21 @@ public class ProcedureQueryCacheKeyTest 
         assertEquals("proc:", md1.getCacheKey());
     }
 
+    public void testCacheFetchOffsetAndLimit() {
+        EntityResolver resolver = runtime.getDataDomain().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/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateCacheKeyTest.java
Thu Jul  7 10:04:11 2011
@@ -78,4 +78,19 @@ public class SQLTemplateCacheKeyTest ext
         assertFalse("XYZ".equals(md1.getCacheKey()));
     }
 
+    public void testCacheFetchLimitAndOffset() {
+        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/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java?rev=1143744&r1=1143743&r2=1143744&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
Thu Jul  7 10:04:11 2011
@@ -596,4 +596,31 @@ public class SelectQueryTest extends Ser
                 numbers));
         context.performQuery(query);
     }
+    
+    public void testCacheOffsetAndLimit() throws Exception {
+        createArtistsDataSet();
+        
+        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