cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: CAY-2228 Deprecate multiple cache groups in caching and query API - deprecate multiple cache groups in old API - remove multiple cache groups in 4.0 API - check and alert for multiple cache groups settings in Modeler - chang
Date Wed, 15 Feb 2017 14:08:22 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 8a570a9d2 -> dd1745ca8


http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
b/cayenne-server/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
index 59da8e0..135bbcb 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
@@ -71,7 +71,7 @@ class IncrementalSelectQuery<T> extends SelectQuery<T> {
 		// overriding caching settings in the metadata will only affect
 		// ClientServerChannel behavior
 		return new QueryMetadataProxy(metadata) {
-			public Query getOrginatingQuery() {
+			public Query getOriginatingQuery() {
 				return null;
 			}
 
@@ -136,11 +136,23 @@ class IncrementalSelectQuery<T> extends SelectQuery<T> {
 		return query.equals(obj);
 	}
 
+	/**
+	 * @deprecated since 4.0, use {@link IncrementalSelectQuery#getCacheGroup()}
+	 */
 	@Override
+	@Deprecated
 	public String[] getCacheGroups() {
 		return query.getCacheGroups();
 	}
 
+	/**
+	 * @since 4.0
+	 */
+	@Override
+	public String getCacheGroup() {
+		return super.getCacheGroup();
+	}
+
 	@Override
 	public int getFetchLimit() {
 		return query.getFetchLimit();
@@ -226,9 +238,22 @@ class IncrementalSelectQuery<T> extends SelectQuery<T> {
 		query.route(router, resolver, substitutedQuery);
 	}
 
+	/**
+	 * @deprecated since 4.0 only first cache group will be used
+	 * 			   use {@link IncrementalSelectQuery#setCacheGroup(String)}
+	 */
+	@Override
+	@Deprecated
+	public void setCacheGroups(String... cacheGroups) {
+		query.setCacheGroups(cacheGroups);
+	}
+
+	/**
+	 * @since 4.0
+	 */
 	@Override
-	public void setCacheGroups(String... cachGroups) {
-		query.setCacheGroups(cachGroups);
+	public void setCacheGroup(String cacheGroup) {
+		query.setCacheGroup(cacheGroup);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/main/java/org/apache/cayenne/remote/RangeQuery.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/remote/RangeQuery.java b/cayenne-server/src/main/java/org/apache/cayenne/remote/RangeQuery.java
index 87ba3d3..5c7467e 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/remote/RangeQuery.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/remote/RangeQuery.java
@@ -72,7 +72,12 @@ class RangeQuery implements Query {
 
         return new QueryMetadataProxy(originatingMetadata) {
 
+            @Deprecated
             public Query getOrginatingQuery() {
+                return getOriginatingQuery();
+            }
+
+            public Query getOriginatingQuery() {
                 return originatingQuery;
             }
 
@@ -88,10 +93,15 @@ class RangeQuery implements Query {
                 return cacheKey;
             }
 
+            @Deprecated
             public String[] getCacheGroups() {
                 return null;
             }
 
+            public String getCacheGroup() {
+                return null;
+            }
+
             public int getFetchOffset() {
                 return fetchOffset;
             }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/MockAbstractQuery.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/MockAbstractQuery.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/MockAbstractQuery.java
index 22f377d..62eacf2 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/MockAbstractQuery.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/MockAbstractQuery.java
@@ -36,4 +36,9 @@ public class MockAbstractQuery extends AbstractQuery {
     public SQLAction createSQLAction(SQLActionVisitor visitor) {
         return null;
     }
+
+    @Override
+    protected BaseQueryMetadata getBaseMetaData() {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
index 95f9b28..80c18d1 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
@@ -67,10 +67,15 @@ public class MockQueryMetadata implements QueryMetadata {
         return null;
     }
 
+    @Deprecated
     public String[] getCacheGroups() {
         return null;
     }
 
+    public String getCacheGroup() {
+        return null;
+    }
+
     public ClassDescriptor getClassDescriptor() {
         return null;
     }
@@ -103,10 +108,15 @@ public class MockQueryMetadata implements QueryMetadata {
         return null;
     }
 
+    @Deprecated
     public Query getOrginatingQuery() {
         return null;
     }
 
+    public Query getOriginatingQuery() {
+        return null;
+    }
+
     public int getStatementFetchSize() {
         return 0;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
index 94a7292..dd9e1f2 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.query;
 
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -374,11 +373,11 @@ public class ObjectSelectTest {
 		ObjectSelect<DataRow> q = ObjectSelect.dataRowQuery(Artist.class);
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.cacheGroups(Arrays.asList("a", "b"));
+		q.cacheGroup("a");
 		assertNull(q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("a", q.getCacheGroup());
 	}
 
 	@Test
@@ -386,15 +385,15 @@ public class ObjectSelectTest {
 		ObjectSelect<DataRow> q = ObjectSelect.dataRowQuery(Artist.class);
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, "a", "b");
+		q.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, "b");
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("b", q.getCacheGroup());
 
 		q.cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 	@Test
@@ -402,15 +401,15 @@ public class ObjectSelectTest {
 		ObjectSelect<DataRow> q = ObjectSelect.dataRowQuery(Artist.class);
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.localCache("a", "b");
+		q.localCache("a");
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("a", q.getCacheGroup());
 
 		q.localCache();
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 	@Test
@@ -418,15 +417,15 @@ public class ObjectSelectTest {
 		ObjectSelect<DataRow> q = ObjectSelect.dataRowQuery(Artist.class);
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.sharedCache("a", "b");
+		q.sharedCache("b");
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("b", q.getCacheGroup());
 
 		q.sharedCache();
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
index b0aecb0..7af84e1 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
@@ -67,6 +67,7 @@ public class ObjectSelect_CompileIT extends ServerCase {
 
 		assertEquals(QueryCacheStrategy.NO_CACHE, selectQuery.getCacheStrategy());
 		assertNull(selectQuery.getCacheGroups());
+		assertNull(selectQuery.getCacheGroup());
 		assertEquals(0, selectQuery.getFetchLimit());
 		assertEquals(0, selectQuery.getFetchOffset());
 		assertEquals(0, selectQuery.getPageSize());
@@ -76,11 +77,10 @@ public class ObjectSelect_CompileIT extends ServerCase {
 	@Test
 	public void testCreateReplacementQuery_Full() {
 
-		// add all possible attributes to the query and make sure they got
-		// propagated
+		// add all possible attributes to the query and make sure they got propagated
 		ObjectSelect<Artist> q = ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.eq("me"))
 				.orderBy(Artist.DATE_OF_BIRTH.asc(), Artist.ARTIST_NAME.desc()).prefetch(Artist.PAINTING_ARRAY.joint())
-				.localCache("cg2", "cg1").limit(46).offset(9).pageSize(6).statementFetchSize(789);
+				.localCache("cg2").limit(46).offset(9).pageSize(6).statementFetchSize(789);
 
 		Query replacement = q.createReplacementQuery(resolver);
 		assertThat(replacement, instanceOf(SelectQuery.class));
@@ -102,7 +102,8 @@ public class ObjectSelect_CompileIT extends ServerCase {
 		assertEquals(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS, childPrefetch.getSemantics());
 
 		assertEquals(QueryCacheStrategy.LOCAL_CACHE, selectQuery.getCacheStrategy());
-		assertArrayEquals(new Object[] { "cg2", "cg1" }, selectQuery.getCacheGroups());
+		assertArrayEquals(new String[] { "cg2" }, selectQuery.getCacheGroups());
+		assertEquals("cg2", selectQuery.getCacheGroup());
 
 		assertEquals(46, selectQuery.getFetchLimit());
 		assertEquals(9, selectQuery.getFetchOffset());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectTest.java b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectTest.java
index dcf58c4..a1d2724 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectTest.java
@@ -19,48 +19,30 @@
 package org.apache.cayenne.query;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 import static org.mockito.Mockito.mock;
 
-import java.util.Arrays;
-
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.map.EntityResolver;
 import org.junit.Test;
 
 public class SQLSelectTest {
 
-	@Test
-	public void testCacheGroups_Collection() {
-		SQLSelect<DataRow> q = SQLSelect.dataRowQuery("bla");
-
-		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
-
-		q.cacheGroups(Arrays.asList("a", "b"));
-		assertNull(q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
-	}
 
 	@Test
 	public void testCacheStrategy() {
 		SQLSelect<DataRow> q = SQLSelect.dataRowQuery("bla");
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, "a", "b");
+		q.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, "a");
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("a", q.getCacheGroup());
 
 		q.cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 	@Test
@@ -68,15 +50,15 @@ public class SQLSelectTest {
 		SQLSelect<DataRow> q = SQLSelect.dataRowQuery("bla");
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.localCache("a", "b");
+		q.localCache("a");
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("a", q.getCacheGroup());
 
 		q.localCache();
 		assertSame(QueryCacheStrategy.LOCAL_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 	@Test
@@ -84,15 +66,15 @@ public class SQLSelectTest {
 		SQLSelect<DataRow> q = SQLSelect.dataRowQuery("bla");
 
 		assertNull(q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 
-		q.sharedCache("a", "b");
+		q.sharedCache("a");
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertArrayEquals(new String[] { "a", "b" }, q.getCacheGroups());
+		assertEquals("a", q.getCacheGroup());
 
 		q.sharedCache();
 		assertSame(QueryCacheStrategy.SHARED_CACHE, q.getCacheStrategy());
-		assertNull(q.getCacheGroups());
+		assertNull(q.getCacheGroup());
 	}
 
 	@Test

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryCacheKeyIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryCacheKeyIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryCacheKeyIT.java
index 60cdc16..6f6a4d1 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryCacheKeyIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryCacheKeyIT.java
@@ -42,7 +42,7 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testNoCache() {
 
-        SelectQuery query = new SelectQuery(Artist.class);
+        SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
 
         QueryMetadata md1 = query.getMetaData(resolver);
         assertEquals(QueryCacheStrategy.NO_CACHE, md1.getCacheStrategy());
@@ -57,7 +57,7 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testLocalCache() {
 
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
 
         query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
@@ -69,27 +69,49 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testUseLocalCache() {
 
-        SelectQuery<Artist> q1 = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
         q1.useLocalCache();
 
         QueryMetadata md1 = q1.getMetaData(resolver);
         assertEquals(QueryCacheStrategy.LOCAL_CACHE, md1.getCacheStrategy());
         assertNotNull(md1.getCacheKey());
-        assertEquals(0, md1.getCacheGroups().length);
+        assertNull(md1.getCacheGroup());
         
-        SelectQuery<Artist> q2 = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
+        q2.useLocalCache("g1");
+
+        QueryMetadata md2 = q2.getMetaData(resolver);
+        assertEquals(QueryCacheStrategy.LOCAL_CACHE, md2.getCacheStrategy());
+        assertNotNull(md2.getCacheKey());
+        assertEquals("g1", md2.getCacheGroup());
+    }
+
+    @Test
+    public void testUseLocalCacheOld() {
+
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
+        q1.useLocalCache();
+
+        QueryMetadata md1 = q1.getMetaData(resolver);
+        assertEquals(QueryCacheStrategy.LOCAL_CACHE, md1.getCacheStrategy());
+        assertNotNull(md1.getCacheKey());
+        assertNull(md1.getCacheGroups());
+        assertNull(md1.getCacheGroup());
+
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
         q2.useLocalCache("g1", "g2");
 
         QueryMetadata md2 = q2.getMetaData(resolver);
         assertEquals(QueryCacheStrategy.LOCAL_CACHE, md2.getCacheStrategy());
         assertNotNull(md2.getCacheKey());
-        assertEquals(2, md2.getCacheGroups().length);
+        assertEquals(1, md2.getCacheGroups().length);
+        assertEquals("g1", md2.getCacheGroup());
     }
 
     @Test
     public void testSharedCache() {
 
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
 
         query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
 
@@ -101,27 +123,29 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testUseSharedCache() {
 
-        SelectQuery<Artist> q1 = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
         q1.useSharedCache();
 
         QueryMetadata md1 = q1.getMetaData(resolver);
         assertEquals(QueryCacheStrategy.SHARED_CACHE, md1.getCacheStrategy());
         assertNotNull(md1.getCacheKey());
-        assertEquals(0, md1.getCacheGroups().length);
+        assertNull(md1.getCacheGroups());
+        assertNull(md1.getCacheGroup());
         
-        SelectQuery<Artist> q2 = new SelectQuery<Artist>(Artist.class);
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
         q2.useSharedCache("g1", "g2");
 
         QueryMetadata md2 = q2.getMetaData(resolver);
         assertEquals(QueryCacheStrategy.SHARED_CACHE, md2.getCacheStrategy());
         assertNotNull(md2.getCacheKey());
-        assertEquals(2, md2.getCacheGroups().length);
+        assertEquals(1, md2.getCacheGroups().length);
+        assertEquals("g1", md2.getCacheGroup());
     }
 
     @Test
     public void testNamedQuery() {
 
-        SelectQuery query = new SelectQuery(Artist.class);
+        SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
 
         query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
         query.setName("XYZ");
@@ -134,13 +158,13 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testUniqueKeyEntity() {
 
-        SelectQuery q1 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
         q1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
-        SelectQuery q2 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
         q2.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
-        SelectQuery q3 = new SelectQuery(Painting.class);
+        SelectQuery<Painting> q3 = new SelectQuery<>(Painting.class);
         q3.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
         assertNotNull(q1.getMetaData(resolver).getCacheKey());
@@ -152,15 +176,15 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testUniqueKeyEntityQualifier() {
 
-        SelectQuery q1 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
         q1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q1.setQualifier(ExpressionFactory.matchExp("a", "b"));
 
-        SelectQuery q2 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
         q2.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q2.setQualifier(ExpressionFactory.matchExp("a", "b"));
 
-        SelectQuery q3 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q3 = new SelectQuery<>(Artist.class);
         q3.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q3.setQualifier(ExpressionFactory.matchExp("a", "c"));
 
@@ -173,19 +197,19 @@ public class SelectQueryCacheKeyIT extends ServerCase {
     @Test
     public void testUniqueKeyEntityFetchLimit() {
 
-        SelectQuery q1 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q1 = new SelectQuery<>(Artist.class);
         q1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q1.setFetchLimit(5);
 
-        SelectQuery q2 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q2 = new SelectQuery<>(Artist.class);
         q2.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q2.setFetchLimit(5);
 
-        SelectQuery q3 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q3 = new SelectQuery<>(Artist.class);
         q3.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         q3.setFetchLimit(6);
 
-        SelectQuery q4 = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q4 = new SelectQuery<>(Artist.class);
         q4.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
         assertNotNull(q1.getMetaData(resolver).getCacheKey());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryPropertiesPanel.java
index 1eaa014..c4ae187 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryPropertiesPanel.java
@@ -44,7 +44,7 @@ public class EjbqlQueryPropertiesPanel extends SelectPropertiesPanel {
         builder.addSeparator("Select Properties", cc.xywh(1, 1, 7, 1));
         builder.addLabel("Result Caching:", cc.xy(1, 3));
         builder.add(cacheStrategy, cc.xywh(3, 3, 5, 1));
-        cacheGroupsLabel = builder.addLabel("Cache Groups:", cc.xy(1, 7));
+        cacheGroupsLabel = builder.addLabel("Cache Group:", cc.xy(1, 7));
         builder.add(cacheGroups.getComponent(), cc.xywh(3, 7, 5, 1));
         builder.addLabel("Fetch Offset, Rows:", cc.xy(1, 9));
         builder.add(fetchOffset.getComponent(), cc.xywh(3, 9, 3, 1));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
index a5d5815..eca066c 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
@@ -58,12 +58,10 @@ public class ObjectQueryPropertiesPanel extends SelectPropertiesPanel
{
                 "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu,
p");
         PanelBuilder builder = new PanelBuilder(layout);
         builder.setDefaultDialogBorder();
-
         builder.addSeparator("", cc.xywh(1, 1, 4, 1));
-
         builder.addLabel("Result Caching:", cc.xy(1, 3));
         builder.add(cacheStrategy, cc.xywh(3, 3, 2, 1));
-        cacheGroupsLabel = builder.addLabel("Cache Groups:", cc.xy(1, 7));
+        cacheGroupsLabel = builder.addLabel("Cache Group:", cc.xy(1, 7));
         builder.add(cacheGroups.getComponent(), cc.xywh(3, 7, 2, 1));
         builder.addLabel("Fetch Data Rows:", cc.xy(1, 9));
         builder.add(dataRows, cc.xy(3, 9));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
index 23c69d7..7717873 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
@@ -287,8 +287,7 @@ public class ProcedureQueryView extends JPanel {
             super.initFromModel(query);
 
             if (query != null && QueryDescriptor.PROCEDURE_QUERY.equals(query.getType()))
{
-                DefaultComboBoxModel labelCaseModel = new DefaultComboBoxModel(
-                        LABEL_CAPITALIZATION);
+                DefaultComboBoxModel labelCaseModel = new DefaultComboBoxModel(LABEL_CAPITALIZATION);
 
                 String columnNameCapitalization = query.getProperty(SQLTemplate.COLUMN_NAME_CAPITALIZATION_PROPERTY);
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
index 616c628..8244aba 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
@@ -84,12 +84,10 @@ public abstract class RawQueryPropertiesPanel extends SelectPropertiesPanel
{
 
         PanelBuilder builder = new PanelBuilder(layout);
         builder.setDefaultDialogBorder();
-
         builder.addSeparator("Select Properties", cc.xywh(1, 1, 7, 1));
-
         builder.addLabel("Result Caching:", cc.xy(1, 3));
         builder.add(cacheStrategy, cc.xywh(3, 3, 5, 1));
-        cacheGroupsLabel = builder.addLabel("Cache Groups:", cc.xy(1, 7));
+        cacheGroupsLabel = builder.addLabel("Cache Group:", cc.xy(1, 7));
         builder.add(cacheGroups.getComponent(), cc.xywh(3, 7, 5, 1));
         builder.addLabel("Fetch Data Objects:", cc.xy(1, 9));
         builder.add(dataObjects, cc.xy(3, 9));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/dd1745ca/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
index 4cfa0e7..2c25f3e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
@@ -55,23 +55,24 @@ public abstract class SelectPropertiesPanel extends JPanel {
 
     private static Log logObj = LogFactory.getLog(SelectPropertiesPanel.class);
 
-    private static final Integer ZERO = new Integer(0);
+    private static final Integer ZERO = 0;
 
     private static final String NO_CACHE_LABEL = "No Result Caching";
     private static final String LOCAL_CACHE_LABEL = "Local Cache (per ObjectContext)";
     private static final String SHARED_CACHE_LABEL = "Shared Cache";
 
     protected static final Object[] CACHE_POLICIES = new Object[] {
-            QueryCacheStrategy.NO_CACHE, QueryCacheStrategy.LOCAL_CACHE,
+            QueryCacheStrategy.NO_CACHE,
+            QueryCacheStrategy.LOCAL_CACHE,
             QueryCacheStrategy.SHARED_CACHE
     };
 
-    private static final Map<QueryCacheStrategy, String> cachePolicyLabels = new TreeMap<QueryCacheStrategy,
String>();
+    private static final Map<QueryCacheStrategy, String> cachePolicyLabels = new TreeMap<>();
 
     static {
-        cachePolicyLabels.put(QueryCacheStrategy.NO_CACHE, NO_CACHE_LABEL);
-        cachePolicyLabels.put(QueryCacheStrategy.LOCAL_CACHE, LOCAL_CACHE_LABEL);
-        cachePolicyLabels.put(QueryCacheStrategy.SHARED_CACHE, SHARED_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.NO_CACHE,      NO_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.LOCAL_CACHE,   LOCAL_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.SHARED_CACHE,  SHARED_CACHE_LABEL);
     }
 
     protected TextAdapter fetchOffset;
@@ -91,21 +92,18 @@ public abstract class SelectPropertiesPanel extends JPanel {
 
     protected void initView() {
         fetchOffset = new TextAdapter(new JTextField(7)) {
-
             protected void updateModel(String text) {
                 setFetchOffset(text);
             }
         };
 
         fetchLimit = new TextAdapter(new JTextField(7)) {
-
             protected void updateModel(String text) {
                 setFetchLimit(text);
             }
         };
 
         pageSize = new TextAdapter(new JTextField(7)) {
-
             protected void updateModel(String text) {
                 setPageSize(text);
             }
@@ -114,7 +112,6 @@ public abstract class SelectPropertiesPanel extends JPanel {
         cacheStrategy = Application.getWidgetFactory().createUndoableComboBox();
         cacheStrategy.setRenderer(new CacheStrategyRenderer());
         cacheGroups = new TextAdapter(new JTextField()) {
-
             protected void updateModel(String text) {
                 setCacheGroups(text);
             }
@@ -123,14 +120,10 @@ public abstract class SelectPropertiesPanel extends JPanel {
 
     protected void initController() {
         cacheStrategy.addActionListener(new ActionListener() {
-
             public void actionPerformed(ActionEvent event) {
-                QueryCacheStrategy strategy = (QueryCacheStrategy) cacheStrategy
-                        .getModel()
-                        .getSelectedItem();
+                QueryCacheStrategy strategy = (QueryCacheStrategy) cacheStrategy.getModel().getSelectedItem();
                 setQueryProperty(QueryMetadata.CACHE_STRATEGY_PROPERTY, strategy.name());
-                setCacheGroupsEnabled(strategy != null
-                        && strategy != QueryCacheStrategy.NO_CACHE);
+                setCacheGroupsEnabled(strategy != QueryCacheStrategy.NO_CACHE);
             }
         });
     }
@@ -153,8 +146,7 @@ public abstract class SelectPropertiesPanel extends JPanel {
         cacheStrategy.setModel(cacheModel);
 
         cacheGroups.setText(query.getProperty(QueryMetadata.CACHE_GROUPS_PROPERTY));
-        setCacheGroupsEnabled(selectedStrategy != null
-                && selectedStrategy != QueryCacheStrategy.NO_CACHE);
+        setCacheGroupsEnabled(selectedStrategy != null && selectedStrategy != QueryCacheStrategy.NO_CACHE);
 
         String fetchOffsetStr = query.getProperty(QueryMetadata.FETCH_OFFSET_PROPERTY);
         String fetchLimitStr = query.getProperty(QueryMetadata.FETCH_LIMIT_PROPERTY);
@@ -165,68 +157,41 @@ public abstract class SelectPropertiesPanel extends JPanel {
         pageSize.setText(pageSizeStr != null ? pageSizeStr : ZERO.toString());
     }
 
-    protected String toCacheGroupsString(String[] groups) {
-
-        StringBuilder buffer = new StringBuilder();
-        if (groups != null && groups.length > 0) {
-
-            for (int i = 0; i < groups.length; i++) {
-                if (i > 0) {
-                    buffer.append(", ");
-                }
-
-                buffer.append(groups[i]);
-            }
-        }
-
-        return buffer.toString();
-    }
-
     void setFetchOffset(String string) {
-        string = (string == null) ? "" : string.trim();
-
+        string = string == null ? "" : string.trim();
         if (string.length() == 0) {
             setQueryProperty(QueryMetadata.FETCH_OFFSET_PROPERTY, ZERO.toString());
-        }
-        else {
+        } else {
             if (StringUtils.isNumeric(string)) {
                 setQueryProperty(QueryMetadata.FETCH_OFFSET_PROPERTY, string);
-            }
-            else {
-                throw new ValidationException("Fetch offset must be an integer: "
-                        + string);
+            } else {
+                throw new ValidationException("Fetch offset must be an integer: %s", string);
             }
         }
     }
 
     void setFetchLimit(String string) {
         string = (string == null) ? "" : string.trim();
-
         if (string.length() == 0) {
             setQueryProperty(QueryMetadata.FETCH_LIMIT_PROPERTY, ZERO.toString());
-        }
-        else {
+        } else {
             if (StringUtils.isNumeric(string)) {
                 setQueryProperty(QueryMetadata.FETCH_LIMIT_PROPERTY, string);
-            }
-            else {
-                throw new ValidationException("Fetch limit must be an integer: " + string);
+            } else {
+                throw new ValidationException("Fetch limit must be an integer: %s", string);
             }
         }
     }
 
     void setPageSize(String string) {
         string = (string == null) ? "" : string.trim();
-
         if (string.length() == 0) {
             setQueryProperty(QueryMetadata.PAGE_SIZE_PROPERTY, ZERO.toString());
-        }
-        else {
+        } else {
             if (StringUtils.isNumeric(string)) {
                 setQueryProperty(QueryMetadata.PAGE_SIZE_PROPERTY, string);
-            }
-            else {
-                throw new ValidationException("Page size must be an integer: " + string);
+            } else {
+                throw new ValidationException("Page size must be an integer: %s", string);
             }
         }
     }


Mime
View raw message