cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [3/4] cayenne git commit: CAY-2467 New type-aware Property API - update client cgen templates - update client tests
Date Fri, 28 Dec 2018 12:38:24 GMT
CAY-2467 New type-aware Property API
  - update client cgen templates
  - update client tests


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/63a32d82
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/63a32d82
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/63a32d82

Branch: refs/heads/master
Commit: 63a32d8248301829617ef6cac3fda2313b281dfd
Parents: 56b64c3
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Fri Dec 28 14:51:58 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Fri Dec 28 14:51:58 2018 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/gen/PropertyUtils.java   |  71 ++--
 .../templates/v4_1/client-superclass.vm         |  27 +-
 .../gen/ClientSuperClassGenerationTest.java     |  23 +-
 .../cayenne/gen/SuperClassGenerationTest.java   |   3 -
 .../org/apache/cayenne/CayenneContextIT.java    |   2 +-
 .../cayenne/CayenneContextInheritanceIT.java    |  42 +-
 .../cayenne/CayenneContextMergeHandlerIT.java   |   8 +-
 .../CayenneContextPaginatedListCachingIT.java   |   8 +-
 .../CayenneContextWithDataContextIT.java        | 178 ++++-----
 .../apache/cayenne/NestedCayenneContextIT.java  | 380 ++++++++-----------
 .../cayenne/access/ClientServerChannelIT.java   |  64 ++--
 .../access/ClientServerChannelQueryIT.java      |  26 +-
 .../cayenne/query/ClientExpressionIT.java       |  96 ++---
 .../query/ClientSelectQueryExpressionIT.java    |   5 +-
 .../remote/ClientChannelServerDiffsIT.java      |   4 +-
 .../remote/RemoteIncrementalFaultListIT.java    |  33 +-
 .../persistent/auto/_ClientMtTable1.java        |  19 +-
 .../persistent/auto/_ClientMtTable2.java        |   9 +-
 .../org/apache/cayenne/access/EmbeddingIT.java  |  17 +
 .../cayenne/testdo/mt/auto/_ClientMtTable1.java |  40 +-
 .../mt/auto/_ClientMtTable1Subclass1.java       |  16 +-
 .../mt/auto/_ClientMtTable1Subclass2.java       |  16 +-
 .../cayenne/testdo/mt/auto/_ClientMtTable2.java |  44 ++-
 .../cayenne/testdo/mt/auto/_ClientMtTable3.java |  52 +--
 .../cayenne/testdo/mt/auto/_ClientMtTable4.java |  19 +-
 .../cayenne/testdo/mt/auto/_ClientMtTable5.java |  19 +-
 .../util/PersistentObjectHolderTest.java        |   4 +-
 .../persistent/client/auto/_Artist.java         |  35 +-
 .../persistent/client/auto/_Gallery.java        |  24 +-
 .../persistent/client/auto/_Painting.java       |  52 +--
 .../persistent/client/auto/_Artist.java         |  41 +-
 .../persistent/client/auto/_Gallery.java        |  24 +-
 .../persistent/client/auto/_Painting.java       |  52 +--
 .../tutorial/persistent/auto/_Artist.java       | 101 ++++-
 .../tutorial/persistent/auto/_Gallery.java      |  83 +++-
 .../tutorial/persistent/auto/_Painting.java     |  93 ++++-
 .../persistent/client/auto/_Artist.java         |  35 +-
 .../persistent/client/auto/_Gallery.java        |  24 +-
 .../persistent/client/auto/_Painting.java       |  50 +--
 .../tutorial/persistent/auto/_Artist.java       | 101 ++++-
 .../tutorial/persistent/auto/_Gallery.java      |  83 +++-
 .../tutorial/persistent/auto/_Painting.java     |  93 ++++-
 .../persistent/client/auto/_Artist.java         |  35 +-
 .../persistent/client/auto/_Gallery.java        |  24 +-
 .../persistent/client/auto/_Painting.java       |  50 +--
 .../tutorial/persistent/auto/_Artist.java       |  11 +-
 .../tutorial/persistent/auto/_Gallery.java      |   8 +-
 .../tutorial/persistent/auto/_Painting.java     |  10 +-
 48 files changed, 1287 insertions(+), 967 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-cgen/src/main/java/org/apache/cayenne/gen/PropertyUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/PropertyUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/PropertyUtils.java
index 4d45db6..d79d502 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/PropertyUtils.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/PropertyUtils.java
@@ -100,9 +100,16 @@ public class PropertyUtils {
     }
 
     public void addImport(ObjRelationship relationship) {
+        addImport(relationship, false);
+    }
+
+    public void addImport(ObjRelationship relationship, boolean client) {
         importUtils.addType(PropertyFactory.class.getName());
-        if (relationship.getTargetEntityName() != null && relationship.getTargetEntity() != null) {
-            importUtils.addType(relationship.getTargetEntity().getClassName());
+        if (relationship.getTargetEntity() != null) {
+            importUtils.addType(client
+                    ? relationship.getTargetEntity().getClientClassName()
+                    : relationship.getTargetEntity().getClassName())
+            ;
         } else {
             importUtils.addType(Persistent.class.getName());
         }
@@ -152,7 +159,7 @@ public class PropertyUtils {
         return BaseProperty.class.getName();
     }
 
-    public String propertyDefinition(ObjAttribute attribute) {
+    public String propertyDefinition(ObjAttribute attribute, boolean client) {
         StringUtils utils = StringUtils.getInstance();
 
         String propertyType = getPropertyTypeForAttribute(attribute);
@@ -169,52 +176,56 @@ public class PropertyUtils {
         );
     }
 
-    public String propertyDefinition(ObjRelationship relationship) {
+    public String propertyDefinition(ObjAttribute attribute) {
+        return propertyDefinition(attribute, false);
+    }
+
+    public String propertyDefinition(ObjRelationship relationship, boolean client) {
         if (relationship.isToMany()) {
-            return toManyRelationshipDefinition(relationship);
+            return toManyRelationshipDefinition(relationship, client);
         } else {
-            return toOneRelationshipDefinition(relationship);
+            return toOneRelationshipDefinition(relationship, client);
         }
     }
 
-    private String toManyRelationshipDefinition(ObjRelationship relationship) {
+    public String propertyDefinition(ObjRelationship relationship) {
+        return propertyDefinition(relationship, false);
+    }
+
+    private String toManyRelationshipDefinition(ObjRelationship relationship, boolean client) {
         if (Map.class.getName().equals(relationship.getCollectionType())) {
-            return mapRelationshipDefinition(relationship);
+            return mapRelationshipDefinition(relationship, client);
         } else {
-            return collectionRelationshipDefinition(relationship);
+            return collectionRelationshipDefinition(relationship, client);
         }
     }
 
-    private String mapRelationshipDefinition(ObjRelationship relationship) {
+    private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) {
         StringUtils utils = StringUtils.getInstance();
 
         String propertyType = getPropertyTypeForJavaClass(relationship);
         String propertyFactoryMethod = factoryMethodForPropertyType(propertyType);
-        String mapKeyType = EntityUtils.getMapKeyTypeInternal(relationship);
-        String attributeType = relationship.getTargetEntity() == null
-                ? Persistent.class.getSimpleName()
-                : relationship.getTargetEntity().getClassName();
+        String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship));
+        String attributeType = getRelatedTypeName(relationship, client);
 
         return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);",
                 importUtils.formatJavaType(propertyType),
-                importUtils.formatJavaType(mapKeyType),
-                importUtils.formatJavaType(attributeType),
+                mapKeyType,
+                attributeType,
                 utils.capitalizedAsConstant(relationship.getName()),
                 propertyFactoryMethod,
                 relationship.getName(),
-                importUtils.formatJavaType(mapKeyType),
-                importUtils.formatJavaType(attributeType)
+                mapKeyType,
+                attributeType
         );
     }
 
-    private String collectionRelationshipDefinition(ObjRelationship relationship) {
+    private String collectionRelationshipDefinition(ObjRelationship relationship, boolean client) {
         StringUtils utils = StringUtils.getInstance();
 
         String propertyType = getPropertyTypeForJavaClass(relationship);
         String propertyFactoryMethod = factoryMethodForPropertyType(propertyType);
-        String entityType = importUtils.formatJavaType(relationship.getTargetEntity() == null
-                ? Persistent.class.getSimpleName()
-                : relationship.getTargetEntity().getClassName());
+        String entityType = getRelatedTypeName(relationship, client);
 
         return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", %s.class);",
                 importUtils.formatJavaType(propertyType),
@@ -226,14 +237,22 @@ public class PropertyUtils {
         );
     }
 
-    private String toOneRelationshipDefinition(ObjRelationship relationship) {
+    private String getRelatedTypeName(ObjRelationship relationship, boolean client) {
+        if(relationship.getTargetEntity() == null) {
+            return Persistent.class.getSimpleName();
+        }
+
+        return importUtils.formatJavaType(client
+                ? relationship.getTargetEntity().getClientClassName()
+                : relationship.getTargetEntity().getClassName());
+    }
+
+    private String toOneRelationshipDefinition(ObjRelationship relationship, boolean client) {
         StringUtils utils = StringUtils.getInstance();
 
         String propertyType = EntityProperty.class.getName();
         String propertyFactoryMethod = "createEntity";
-        String attributeType = (relationship.getTargetEntityName() == null || relationship.getTargetEntity() == null)
-                ? Persistent.class.getSimpleName()
-                : importUtils.formatJavaType(relationship.getTargetEntity().getClassName());
+        String attributeType = getRelatedTypeName(relationship, client);
 
         return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", %s.class);",
                 importUtils.formatJavaType(propertyType),

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
index 5d21ba0..a70336e 100644
--- a/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
+++ b/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
@@ -36,17 +36,11 @@
 ${importUtils.setPackage($superPackageName)}##
 ${importUtils.addReservedType("${$superPackageName}.${superClassName}")}##
 ${importUtils.addType("${basePackageName}.${baseClassName}")}##
-#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
 #foreach( $attr in ${object.DeclaredAttributes} )
-$importUtils.addType(${attr.Type})##
+$propertyUtils.addImport($attr)##
 #end
 #foreach( $rel in ${object.DeclaredRelationships} )
-$importUtils.addType(${rel.TargetEntity.ClientClassName})##
-#if(${rel.CollectionType}) 
-$importUtils.addType(${rel.CollectionType})##
-#end
+$propertyUtils.addImport($rel, true)##
 #end
 #if( ${entityUtils.hasToOneDeclaredRelationships()} )
 ${importUtils.addType('org.apache.cayenne.ValueHolder')}##
@@ -76,22 +70,10 @@ public abstract class ${superClassName} extends ${baseClassName} {
 #end
 ## Create Properties
 #foreach( $attr in ${object.DeclaredAttributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+    $propertyUtils.propertyDefinition($attr, true)
 #end
 #foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#else
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#else
-    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
+    $propertyUtils.propertyDefinition($rel, true)
 #end
 
 ## Create ivars
@@ -228,7 +210,6 @@ public abstract class ${superClassName} extends ${baseClassName} {
     public void set${stringUtils.capitalized($rel.Name)}(${importUtils.formatJavaType($rel.TargetEntity.ClientClassName)} $relName) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "$rel.Name", true);
-            objectContext.propertyChanged(this, "$rel.Name", this.${relName}.getValueDirectly(), $relName);
         } else if (this.$relName == null) {
         	this.$relName = new PersistentObjectHolder<>(this, "$rel.Name");
 		}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
index b690367..083ff50 100644
--- a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
@@ -38,20 +38,25 @@ public class ClientSuperClassGenerationTest extends ClassGenerationCase {
         context.put(Artifact.OBJECT_KEY, objEntity);
 
         String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
+        assertFalse(res.contains("org.apache.cayenne.exp.property."));
     }
 
     @Test
     public void testContainsPropertyImportForAttributes() throws Exception {
         ObjEntity objEntity = new ObjEntity("TEST1");
         ObjAttribute attr = new ObjAttribute("attr");
+        attr.setType("int");
         objEntity.addAttribute(attr);
 
         VelocityContext context = new VelocityContext();
+        ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
+        context.put(Artifact.IMPORT_UTILS_KEY, importUtils);
+        context.put(Artifact.STRING_UTILS_KEY, StringUtils.getInstance());
+        context.put(Artifact.PROPERTY_UTILS_KEY, new PropertyUtils(importUtils));
 
         String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+        assertTrue(res.contains("org.apache.cayenne.exp.property.NumericProperty"));
     }
 
     @Test
@@ -61,26 +66,36 @@ public class ClientSuperClassGenerationTest extends ClassGenerationCase {
         objEntity.addRelationship(rel);
 
         VelocityContext context = new VelocityContext();
+        ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
+        context.put(Artifact.IMPORT_UTILS_KEY, importUtils);
+        context.put(Artifact.STRING_UTILS_KEY, StringUtils.getInstance());
+        context.put(Artifact.PROPERTY_UTILS_KEY, new PropertyUtils(importUtils));
 
         String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+        assertTrue(res.contains("org.apache.cayenne.exp.property.EntityProperty"));
     }
 
     @Test
     public void testContainsPropertyImport() throws Exception {
         ObjEntity objEntity = new ObjEntity("TEST1");
         ObjAttribute attr = new ObjAttribute("attr");
+        attr.setType("int");
         ObjRelationship rel = new ObjRelationship("rel");
 
         objEntity.addAttribute(attr);
         objEntity.addRelationship(rel);
 
         VelocityContext context = new VelocityContext();
+        ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
+        context.put(Artifact.IMPORT_UTILS_KEY, importUtils);
+        context.put(Artifact.STRING_UTILS_KEY, StringUtils.getInstance());
+        context.put(Artifact.PROPERTY_UTILS_KEY, new PropertyUtils(importUtils));
 
         String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+        assertTrue(res.contains("org.apache.cayenne.exp.property.NumericProperty"));
+        assertTrue(res.contains("org.apache.cayenne.exp.property.EntityProperty"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
index 8acaba3..704b01b 100644
--- a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
@@ -37,7 +37,6 @@ public class SuperClassGenerationTest extends ClassGenerationCase {
         ObjEntity objEntity = new ObjEntity("TEST1");
 
         VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
         ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
         context.put(Artifact.IMPORT_UTILS_KEY, importUtils);
@@ -57,7 +56,6 @@ public class SuperClassGenerationTest extends ClassGenerationCase {
         objEntity.addAttribute(attr);
 
         VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
         ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
         context.put(Artifact.IMPORT_UTILS_KEY, importUtils);
@@ -76,7 +74,6 @@ public class SuperClassGenerationTest extends ClassGenerationCase {
         objEntity.addRelationship(rel);
 
         VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
         ImportUtils importUtils = new ImportUtils();
         context.put(Artifact.OBJECT_KEY, objEntity);
         context.put(Artifact.IMPORT_UTILS_KEY, importUtils);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextIT.java
index cb44912..33bd5e8 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextIT.java
@@ -296,7 +296,7 @@ public class CayenneContextIT extends ClientCase {
 		context.graphManager.registerNode(hollow.getObjectId(), hollow);
 
 		// testing this...
-		context.prepareForAccess(hollow, ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, false);
+		context.prepareForAccess(hollow, ClientMtTable1.GLOBAL_ATTRIBUTE1.getName(), false);
 		assertTrue(selectExecuted[0]);
 		assertSame(hollow, context.getGraphManager().getNode(gid));
 		assertEquals(inflated.getGlobalAttribute1Direct(), hollow.getGlobalAttribute1Direct());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextInheritanceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextInheritanceIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextInheritanceIT.java
index 1862616..fc13b66 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextInheritanceIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextInheritanceIT.java
@@ -84,8 +84,8 @@ public class CayenneContextInheritanceIT extends ClientCase {
         tMtTable1.insert(2, "sub1", "zzz", "sa1");
         tMtTable1.insert(3, "1111", "aaa", null);
 
-        SelectQuery query = new SelectQuery(ClientMtTable1Subclass1.class);
-        List<ClientMtTable1Subclass1> objects = context.performQuery(query);
+        SelectQuery<ClientMtTable1Subclass1> query = new SelectQuery<>(ClientMtTable1Subclass1.class);
+        List<ClientMtTable1Subclass1> objects = query.select(context);
 
         assertEquals(1, objects.size());
         assertEquals("sa1", objects.get(0).getSubclass1Attribute1());
@@ -98,22 +98,19 @@ public class CayenneContextInheritanceIT extends ClientCase {
         tMtTable1.insert(2, "sub1", "zzz", "sa1");
         tMtTable1.insert(3, "z", "aaa", null);
 
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
-        List<ClientMtTable1> objects = context.performQuery(query);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
+        List<ClientMtTable1> objects = query.select(context);
 
         assertEquals(3, objects.size());
 
         int checkedFields = 0;
-        for (int i = 0; i < objects.size(); i++) {
-            Integer id = (Integer) objects.get(i).getObjectId().getIdSnapshot().get(
-                    "TABLE1_ID");
+        for (ClientMtTable1 object : objects) {
+            Integer id = (Integer) object.getObjectId().getIdSnapshot().get("TABLE1_ID");
             if (id == 1) {
-                assertEquals("a", objects.get(i).getGlobalAttribute1());
+                assertEquals("a", object.getGlobalAttribute1());
                 checkedFields++;
-            }
-            else if (id == 2) {
-                assertEquals("sa1", ((ClientMtTable1Subclass1) objects.get(i))
-                        .getSubclass1Attribute1());
+            } else if (id == 2) {
+                assertEquals("sa1", ((ClientMtTable1Subclass1) object).getSubclass1Attribute1());
                 checkedFields++;
             }
 
@@ -128,25 +125,20 @@ public class CayenneContextInheritanceIT extends ClientCase {
         tMtTable1.insert(2, "sub1", "XXA", "sa1");
         tMtTable1.insert(3, "z", "MM", null);
 
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
-        query.andQualifier(ExpressionFactory.likeExp(
-                ClientMtTable1.SERVER_ATTRIBUTE1_PROPERTY,
-                "X%"));
-        List<ClientMtTable1> objects = context.performQuery(query);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
+        query.andQualifier(ClientMtTable1.SERVER_ATTRIBUTE1.like("X%"));
+        List<ClientMtTable1> objects = query.select(context);
 
         assertEquals(2, objects.size());
 
         int checkedFields = 0;
-        for (int i = 0; i < objects.size(); i++) {
-            Integer id = (Integer) objects.get(i).getObjectId().getIdSnapshot().get(
-                    "TABLE1_ID");
+        for (ClientMtTable1 object : objects) {
+            Integer id = (Integer) object.getObjectId().getIdSnapshot().get("TABLE1_ID");
             if (id == 1) {
-                assertEquals("a", objects.get(i).getGlobalAttribute1());
+                assertEquals("a", object.getGlobalAttribute1());
                 checkedFields++;
-            }
-            else if (id == 2) {
-                assertEquals("sa1", ((ClientMtTable1Subclass1) objects.get(i))
-                        .getSubclass1Attribute1());
+            } else if (id == 2) {
+                assertEquals("sa1", ((ClientMtTable1Subclass1) object).getSubclass1Attribute1());
                 checkedFields++;
             }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextMergeHandlerIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextMergeHandlerIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextMergeHandlerIT.java
index 00ca30e..19e8e78 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextMergeHandlerIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextMergeHandlerIT.java
@@ -79,19 +79,19 @@ public class CayenneContextMergeHandlerIT extends ClientCase {
 
         assertNull(o1.getGlobalAttribute1Direct());
 
-        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, null, "abc");
+        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1.getName(), null, "abc");
         assertEquals("abc", o1.getGlobalAttribute1Direct());
 
-        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "abc", "xyz");
+        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1.getName(), "abc", "xyz");
 
         assertEquals("xyz", o1.getGlobalAttribute1Direct());
 
         // block if old value is different
-        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "123", "mnk");
+        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1.getName(), "123", "mnk");
 
         assertEquals("xyz", o1.getGlobalAttribute1Direct());
 
-        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "xyz", null);
+        handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1.getName(), "xyz", null);
 
         assertNull(o1.getGlobalAttribute1Direct());
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextPaginatedListCachingIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextPaginatedListCachingIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextPaginatedListCachingIT.java
index ee5565a..521d64e 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextPaginatedListCachingIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextPaginatedListCachingIT.java
@@ -52,7 +52,7 @@ public class CayenneContextPaginatedListCachingIT extends ClientCase {
         tMtTable1.setColumns("TABLE1_ID", "GLOBAL_ATTRIBUTE1", "SERVER_ATTRIBUTE1");
     }
 
-    protected void createSevenMtTable1sDataSet() throws Exception {
+    private void createSevenMtTable1sDataSet() throws Exception {
         for (int i = 1; i <= 7; i++) {
             tMtTable1.insert(i, "g" + i, "s" + i);
         }
@@ -62,12 +62,12 @@ public class CayenneContextPaginatedListCachingIT extends ClientCase {
     public void testLocalCache() throws Exception {
         createSevenMtTable1sDataSet();
 
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
-        query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
+        query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
         query.setPageSize(3);
         query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
-        List<ClientMtTable1> result1 = context.performQuery(query);
+        List<ClientMtTable1> result1 = query.select(context);
         assertEquals(7, result1.size());
 
         // ensure we can resolve all objects without a failure...

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextWithDataContextIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextWithDataContextIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextWithDataContextIT.java
index 6bddc00..c910c30 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextWithDataContextIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextWithDataContextIT.java
@@ -26,7 +26,6 @@ import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.QueryCacheStrategy;
 import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
 import org.apache.cayenne.remote.RemoteIncrementalFaultList;
 import org.apache.cayenne.test.jdbc.DBHelper;
@@ -36,7 +35,6 @@ import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.testdo.mt.MtTable1;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.client.ClientCase;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
@@ -44,7 +42,6 @@ import org.junit.Before;
 import org.junit.Test;
 
 import java.sql.Types;
-import java.util.Iterator;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
@@ -97,13 +94,9 @@ public class CayenneContextWithDataContextIT extends ClientCase {
         }
     }
 
-    @SuppressWarnings("deprecation")
     @Test
     public void testLocalCacheStaysLocal() {
-
-        DataContext serverContext = (DataContext) clientServerChannel.getParentChannel();
-
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
         query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
 
         List<?> results = clientContext.performQuery(query);
@@ -114,7 +107,7 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     }
 
     @Test
-    public void testAddToList() throws Exception {
+    public void testAddToList() {
 
         ClientMtTable1 t1 = clientContext.newObject(ClientMtTable1.class);
         ClientMtTable2 t2 = clientContext.newObject(ClientMtTable2.class);
@@ -133,7 +126,7 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     }
 
     @Test
-    public void testSetValueHolder() throws Exception {
+    public void testSetValueHolder() {
 
         ClientMtTable1 t1 = clientContext.newObject(ClientMtTable1.class);
         ClientMtTable2 t2 = clientContext.newObject(ClientMtTable2.class);
@@ -144,7 +137,7 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     }
 
     @Test
-    public void testPostAddCallback() throws Exception {
+    public void testPostAddCallback() {
 
         LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
@@ -213,11 +206,9 @@ public class CayenneContextWithDataContextIT extends ClientCase {
         new ParallelTestContainer() {
 
             @Override
-            protected void assertResult() throws Exception {
+            protected void assertResult() {
             	// find peer
-            	MtTable1 peer = (MtTable1) serverContext.getGraphManager().getNode(
-                    clientObject.getObjectId());
-
+            	MtTable1 peer = (MtTable1) serverContext.getGraphManager().getNode(clientObject.getObjectId());
             	assertNotNull(peer);
             	assertTrue(peer.isPrePersisted());
             }
@@ -231,7 +222,7 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     }
 
     @Test
-    public void testPreRemoveCallback() throws Exception {
+    public void testPreRemoveCallback() {
 
         // an exception was triggered within POST_LOAD callback
         LifecycleCallbackRegistry callbackRegistry = clientServerChannel
@@ -285,7 +276,7 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     }
 
     @Test
-    public void testRollbackChanges() throws Exception {
+    public void testRollbackChanges() {
 
         ClientMtTable1 o = clientContext.newObject(ClientMtTable1.class);
         o.setGlobalAttribute1("1");
@@ -352,27 +343,24 @@ public class CayenneContextWithDataContextIT extends ClientCase {
                 MtTable1.TABLE1_ID_PK_COLUMN,
                 1);
 
-        SelectQuery q = new SelectQuery(ClientMtTable2.class);
-        q.addOrdering(ClientMtTable2.GLOBAL_ATTRIBUTE_PROPERTY, SortOrder.ASCENDING);
-        q.addPrefetch(ClientMtTable2.TABLE1_PROPERTY);
-
-        final List<ClientMtTable2> results = clientContext.performQuery(q);
+        SelectQuery<ClientMtTable2> q = new SelectQuery<>(ClientMtTable2.class);
+        q.addOrdering(ClientMtTable2.GLOBAL_ATTRIBUTE.asc());
+        q.addPrefetch(ClientMtTable2.TABLE1.disjoint());
 
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        final List<ClientMtTable2> results = q.select(clientContext);
 
-            public void execute() {
-                assertEquals(2, results.size());
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
+            assertEquals(2, results.size());
 
-                for (ClientMtTable2 o : results) {
-                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
-                    assertSame(clientContext, o.getObjectContext());
+            for (ClientMtTable2 o : results) {
+                assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+                assertSame(clientContext, o.getObjectContext());
 
-                    ClientMtTable1 o1 = o.getTable1();
-                    assertNotNull(o1);
-                    assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
-                    assertSame(clientContext, o1.getObjectContext());
-                    assertEquals(prefetchedId, o1.getObjectId());
-                }
+                ClientMtTable1 o1 = o.getTable1();
+                assertNotNull(o1);
+                assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+                assertSame(clientContext, o1.getObjectContext());
+                assertEquals(prefetchedId, o1.getObjectId());
             }
         });
     }
@@ -381,23 +369,19 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     public void testPrefetchingToOneNull() throws Exception {
         tMtTable2.insert(15, null, "g3");
 
-        SelectQuery q = new SelectQuery(ClientMtTable2.class);
-        q.addPrefetch(ClientMtTable2.TABLE1_PROPERTY);
-
-        final List<ClientMtTable2> results = clientContext.performQuery(q);
+        SelectQuery<ClientMtTable2> q = new SelectQuery<>(ClientMtTable2.class);
+        q.addPrefetch(ClientMtTable2.TABLE1.disjoint());
 
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        final List<ClientMtTable2> results = q.select(clientContext);
 
-            public void execute() {
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
+            assertEquals(1, results.size());
 
-                assertEquals(1, results.size());
-
-                ClientMtTable2 o = results.get(0);
-                assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
-                assertSame(clientContext, o.getObjectContext());
+            ClientMtTable2 o = results.get(0);
+            assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+            assertSame(clientContext, o.getObjectContext());
 
-                assertNull(o.getTable1());
-            }
+            assertNull(o.getTable1());
         });
     }
 
@@ -405,33 +389,28 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     public void testPrefetchingToMany() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class);
-        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
-        q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
-
-        final List<ClientMtTable1> results = clientContext.performQuery(q);
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class);
+        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
+        q.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
 
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        final List<ClientMtTable1> results = q.select(clientContext);
 
-            public void execute() {
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
 
-                ClientMtTable1 o1 = results.get(0);
-                assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
-                assertSame(clientContext, o1.getObjectContext());
+            ClientMtTable1 o1 = results.get(0);
+            assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+            assertSame(clientContext, o1.getObjectContext());
 
-                List<?> children1 = o1.getTable2Array();
+            List<ClientMtTable2> children1 = o1.getTable2Array();
 
-                assertEquals(2, children1.size());
-                Iterator<?> it = children1.iterator();
-                while (it.hasNext()) {
-                    ClientMtTable2 o = (ClientMtTable2) it.next();
-                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
-                    assertSame(clientContext, o.getObjectContext());
+            assertEquals(2, children1.size());
+            for (ClientMtTable2 o : children1) {
+                assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+                assertSame(clientContext, o.getObjectContext());
 
-                    // TODO: fixme... reverse relationship is not connected and will
-                    // cause a fetch
-                    // assertEquals(o1, o.getTable1());
-                }
+                // TODO: fixme... reverse relationship is not connected and will
+                // cause a fetch
+                // assertEquals(o1, o.getTable1());
             }
         });
     }
@@ -440,9 +419,9 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     public void testPerformPaginatedQuery() throws Exception {
         createEightMtTable1s();
 
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
         query.setPageSize(5);
-        List<ClientMtTable1> objects = clientContext.performQuery(query);
+        List<ClientMtTable1> objects = query.select(clientContext);
         assertNotNull(objects);
         assertTrue(objects instanceof RemoteIncrementalFaultList);
     }
@@ -451,62 +430,47 @@ public class CayenneContextWithDataContextIT extends ClientCase {
     public void testPrefetchingToManyEmpty() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class);
-        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
-        q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class);
+        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
+        q.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
 
-        final List<ClientMtTable1> results = clientContext.performQuery(q);
+        final List<ClientMtTable1> results = q.select(clientContext);
 
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
+            ClientMtTable1 o2 = results.get(1);
+            assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
+            assertSame(clientContext, o2.getObjectContext());
 
-            public void execute() {
-                ClientMtTable1 o2 = results.get(1);
-                assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
-                assertSame(clientContext, o2.getObjectContext());
-
-                List<ClientMtTable2> children2 = o2.getTable2Array();
-                assertFalse(((ValueHolder) children2).isFault());
-                assertEquals(0, children2.size());
-            }
+            List<ClientMtTable2> children2 = o2.getTable2Array();
+            assertFalse(((ValueHolder) children2).isFault());
+            assertEquals(0, children2.size());
         });
     }
 
     @Test
-    public void testOIDQueryInterception() throws Exception {
+    public void testOIDQueryInterception() {
 
         final ClientMtTable1 o = clientContext.newObject(ClientMtTable1.class);
         o.setGlobalAttribute1("aaa");
 
         // fetch new
-        final ObjectIdQuery q1 = new ObjectIdQuery(
-                o.getObjectId(),
-                false,
-                ObjectIdQuery.CACHE);
-
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        final ObjectIdQuery q1 = new ObjectIdQuery(o.getObjectId(), false, ObjectIdQuery.CACHE);
 
-            public void execute() {
-                List<?> objects = clientContext.performQuery(q1);
-                assertEquals(1, objects.size());
-                assertSame(o, objects.get(0));
-            }
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
+            List<?> objects = clientContext.performQuery(q1);
+            assertEquals(1, objects.size());
+            assertSame(o, objects.get(0));
         });
 
         clientContext.commitChanges();
 
         // fetch committed
-        final ObjectIdQuery q2 = new ObjectIdQuery(
-                o.getObjectId(),
-                false,
-                ObjectIdQuery.CACHE);
-
-        clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        final ObjectIdQuery q2 = new ObjectIdQuery(o.getObjectId(), false, ObjectIdQuery.CACHE);
 
-            public void execute() {
-                List<?> objects = clientContext.performQuery(q2);
-                assertEquals(1, objects.size());
-                assertSame(o, objects.get(0));
-            }
+        clientServerInterceptor.runWithQueriesBlocked(() -> {
+            List<?> objects = clientContext.performQuery(q2);
+            assertEquals(1, objects.size());
+            assertSame(o, objects.get(0));
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/NestedCayenneContextIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/NestedCayenneContextIT.java b/cayenne-client/src/test/java/org/apache/cayenne/NestedCayenneContextIT.java
index 53a3145..83fad72 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/NestedCayenneContextIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/NestedCayenneContextIT.java
@@ -22,6 +22,7 @@ import org.apache.cayenne.configuration.rop.client.ClientRuntime;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.graph.GraphChangeHandler;
 import org.apache.cayenne.graph.GraphDiff;
+import org.apache.cayenne.query.SelectById;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
 import org.apache.cayenne.remote.RemoteCayenneCase;
@@ -29,7 +30,6 @@ import org.apache.cayenne.remote.service.LocalConnection;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Test;
@@ -39,7 +39,6 @@ import org.junit.runners.Parameterized.Parameters;
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
@@ -81,18 +80,17 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		assertSame(clientContext, child.getChannel());
 
 		// second level of nesting
-		ObjectContext grandchild = runtime.newContext((DataChannel) child);
+		ObjectContext grandchild = runtime.newContext(child);
 
 		assertNotNull(grandchild);
 		assertSame(child, grandchild.getChannel());
 	}
 
 	@Test
-	public void testSelect() throws Exception {
+	public void testSelect() {
 		ObjectContext child = runtime.newContext(clientContext);
 
-		ClientMtTable1 committed = clientContext
-				.newObject(ClientMtTable1.class);
+		ClientMtTable1 committed = clientContext.newObject(ClientMtTable1.class);
 		ClientMtTable1 deleted = clientContext.newObject(ClientMtTable1.class);
 		ClientMtTable1 modified = clientContext.newObject(ClientMtTable1.class);
 
@@ -106,16 +104,14 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 
 		ClientMtTable1 _new = clientContext.newObject(ClientMtTable1.class);
 
-		assertEquals(PersistenceState.COMMITTED,
-				committed.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
 		assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
 		assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
 		assertEquals(PersistenceState.NEW, _new.getPersistenceState());
 
 		List<ClientMtTable1> objects = child
-				.select(new SelectQuery<ClientMtTable1>(ClientMtTable1.class));
-		assertEquals("All but NEW object must have been included", 3,
-				objects.size());
+				.select(new SelectQuery<>(ClientMtTable1.class));
+		assertEquals("All but NEW object must have been included", 3, objects.size());
 
 		for (ClientMtTable1 next : objects) {
 			assertEquals(PersistenceState.COMMITTED, next.getPersistenceState());
@@ -128,9 +124,8 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testPrefetchingToOne() throws Exception {
-		final ClientMtTable1 mt11 = clientContext
-				.newObject(ClientMtTable1.class);
+	public void testPrefetchingToOne() {
+		final ClientMtTable1 mt11 = clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
 		ClientMtTable2 mt21 = clientContext.newObject(ClientMtTable2.class);
 		ClientMtTable2 mt22 = clientContext.newObject(ClientMtTable2.class);
@@ -142,36 +137,28 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 
 		final ObjectContext child = runtime.newContext(clientContext);
 
-		SelectQuery<ClientMtTable2> q = new SelectQuery<ClientMtTable2>(
-				ClientMtTable2.class);
-		q.addPrefetch(ClientMtTable2.TABLE1_PROPERTY);
+		SelectQuery<ClientMtTable2> q = new SelectQuery<>(ClientMtTable2.class);
+		q.addPrefetch(ClientMtTable2.TABLE1.getName());
 
 		final List<ClientMtTable2> results = child.select(q);
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-			public void execute() {
-				assertEquals(2, results.size());
-				Iterator<?> it = results.iterator();
-				while (it.hasNext()) {
-					ClientMtTable2 o = (ClientMtTable2) it.next();
-					assertEquals(PersistenceState.COMMITTED,
-							o.getPersistenceState());
-					assertSame(child, o.getObjectContext());
-
-					ClientMtTable1 o1 = o.getTable1();
-					assertNotNull(o1);
-					assertEquals(PersistenceState.COMMITTED,
-							o1.getPersistenceState());
-					assertSame(child, o1.getObjectContext());
-					assertEquals(mt11.getObjectId(), o1.getObjectId());
-				}
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			assertEquals(2, results.size());
+			for (ClientMtTable2 o : results) {
+				assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+				assertSame(child, o.getObjectContext());
+
+				ClientMtTable1 o1 = o.getTable1();
+				assertNotNull(o1);
+				assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+				assertSame(child, o1.getObjectContext());
+				assertEquals(mt11.getObjectId(), o1.getObjectId());
 			}
 		});
 	}
 
 	@Test
-	public void testPrefetchingToMany() throws Exception {
+	public void testPrefetchingToMany() {
 		ClientMtTable1 mt11 = clientContext.newObject(ClientMtTable1.class);
 		mt11.setGlobalAttribute1("1");
 
@@ -188,56 +175,46 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 
 		final ObjectContext child = runtime.newContext(clientContext);
 
-		SelectQuery<ClientMtTable1> q = new SelectQuery<ClientMtTable1>(
+		SelectQuery<ClientMtTable1> q = new SelectQuery<>(
 				ClientMtTable1.class);
 		q.addOrdering("globalAttribute1", SortOrder.ASCENDING);
-		q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
+		q.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
 
 		final List<ClientMtTable1> results = child.select(q);
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			ClientMtTable1 o1 = results.get(0);
+			assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+			assertSame(child, o1.getObjectContext());
 
-			public void execute() {
-				ClientMtTable1 o1 = results.get(0);
-				assertEquals(PersistenceState.COMMITTED,
-						o1.getPersistenceState());
-				assertSame(child, o1.getObjectContext());
+			List<ClientMtTable2> children1 = o1.getTable2Array();
 
-				List<ClientMtTable2> children1 = o1.getTable2Array();
-
-				assertEquals(2, children1.size());
-				Iterator<ClientMtTable2> it = children1.iterator();
-				while (it.hasNext()) {
-					ClientMtTable2 o = it.next();
-					assertEquals(PersistenceState.COMMITTED,
-							o.getPersistenceState());
-					assertSame(child, o.getObjectContext());
-
-					assertEquals(o1, o.getTable1());
-				}
+			assertEquals(2, children1.size());
+			for (ClientMtTable2 o : children1) {
+				assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+				assertSame(child, o.getObjectContext());
+				assertEquals(o1, o.getTable1());
+			}
 
-				ClientMtTable1 o2 = results.get(1);
-				assertEquals(PersistenceState.COMMITTED,
-						o2.getPersistenceState());
-				assertSame(child, o2.getObjectContext());
+			ClientMtTable1 o2 = results.get(1);
+			assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
+			assertSame(child, o2.getObjectContext());
 
-				List<?> children2 = o2.getTable2Array();
+			List<?> children2 = o2.getTable2Array();
 
-				assertEquals(0, children2.size());
-			}
+			assertEquals(0, children2.size());
 		});
 	}
 
 	@Test
-	public void testDeleteNew() throws Exception {
+	public void testDeleteNew() {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class);
 		clientContext.commitChanges();
 
 		ClientMtTable2 p = child.newObject(ClientMtTable2.class);
-		ClientMtTable1 aChild = (ClientMtTable1) Cayenne.objectForPK(child,
-				a.getObjectId());
+		ClientMtTable1 aChild = (ClientMtTable1) Cayenne.objectForPK(child, a.getObjectId());
 		p.setGlobalAttribute("X");
 		aChild.addToTable2Array(p);
 
@@ -253,78 +230,65 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	 * A test case for CAY-698 bug.
 	 */
 	@Test
-	public void testNullifyToOne() throws Exception {
+	public void testNullifyToOne() {
 		ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class);
 		ClientMtTable2 b = clientContext.newObject(ClientMtTable2.class);
 		a.addToTable2Array(b);
 
 		clientContext.commitChanges();
 
-		final ObjectContext child = runtime.newContext(clientContext);
+		ObjectContext child = runtime.newContext(clientContext);
 		ObjectContext childPeer = runtime.newContext(clientContext);
 
-		final ClientMtTable2 childP1 = (ClientMtTable2) Cayenne.objectForPK(
-				child, b.getObjectId());
+		ClientMtTable2 childP1 = SelectById.query(ClientMtTable2.class, b.getObjectId()).selectOne(child);
 
 		// trigger object creation in the peer nested DC
 		Cayenne.objectForPK(childPeer, b.getObjectId());
 		childP1.setTable1(null);
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-			public void execute() {
-				child.commitChangesToParent();
-				assertEquals(PersistenceState.COMMITTED,
-						childP1.getPersistenceState());
-
-				ClientMtTable2 parentP1 = (ClientMtTable2) clientContext
-						.getGraphManager().getNode(childP1.getObjectId());
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			child.commitChangesToParent();
+			assertEquals(PersistenceState.COMMITTED, childP1.getPersistenceState());
 
-				assertNotNull(parentP1);
-				assertEquals(PersistenceState.MODIFIED,
-						parentP1.getPersistenceState());
-				assertNull(parentP1.getTable1());
+			ClientMtTable2 parentP1 = (ClientMtTable2) clientContext.getGraphManager().getNode(childP1.getObjectId());
 
-				// check that arc changes got recorded in the parent context
-				GraphDiff diffs = clientContext.internalGraphManager()
-						.getDiffs();
-				final int[] arcDiffs = new int[1];
+			assertNotNull(parentP1);
+			assertEquals(PersistenceState.MODIFIED, parentP1.getPersistenceState());
+			assertNull(parentP1.getTable1());
 
-				diffs.apply(new GraphChangeHandler() {
+			// check that arc changes got recorded in the parent context
+			GraphDiff diffs = clientContext.internalGraphManager().getDiffs();
+			final int[] arcDiffs = new int[1];
 
-					public void arcCreated(Object nodeId, Object targetNodeId,
-							Object arcId) {
-						arcDiffs[0]++;
-					}
-
-					public void arcDeleted(Object nodeId, Object targetNodeId,
-							Object arcId) {
-						arcDiffs[0]--;
-					}
-
-					public void nodeCreated(Object nodeId) {
+			diffs.apply(new GraphChangeHandler() {
+				public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) {
+					arcDiffs[0]++;
+				}
 
-					}
+				public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) {
+					arcDiffs[0]--;
+				}
 
-					public void nodeIdChanged(Object nodeId, Object newId) {
-					}
+				public void nodeCreated(Object nodeId) {
+				}
 
-					public void nodePropertyChanged(Object nodeId,
-							String property, Object oldValue, Object newValue) {
-					}
+				public void nodeIdChanged(Object nodeId, Object newId) {
+				}
 
-					public void nodeRemoved(Object nodeId) {
+				public void nodePropertyChanged(Object nodeId,
+						String property, Object oldValue, Object newValue) {
+				}
 
-					}
-				});
+				public void nodeRemoved(Object nodeId) {
+				}
+			});
 
-				assertEquals(-2, arcDiffs[0]);
-			}
+			assertEquals(-2, arcDiffs[0]);
 		});
 	}
 
 	@Test
-	public void testCommitChangesToParent() throws Exception {
+	public void testCommitChangesToParent() {
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
@@ -333,8 +297,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 
 		final ObjectContext child = runtime.newContext(clientContext);
 
-		SelectQuery<ClientMtTable1> query = new SelectQuery<ClientMtTable1>(
-				ClientMtTable1.class);
+		SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
 		List<ClientMtTable1> objects = child.select(query);
 
 		assertEquals(4, objects.size());
@@ -350,101 +313,82 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		final ClientMtTable1 childHollow = objects.get(3);
 		child.invalidateObjects(childHollow);
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-			public void execute() {
-				child.commitChangesToParent();
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			child.commitChangesToParent();
 
-				// * all modified child objects must be in committed state now
-				// * all modifications should be propagated to the parent
-				// * no actual commit should occur.
+			// * all modified child objects must be in committed state now
+			// * all modifications should be propagated to the parent
+			// * no actual commit should occur.
 
-				assertEquals(PersistenceState.COMMITTED,
-						childNew.getPersistenceState());
-				assertEquals(PersistenceState.COMMITTED,
-						childModified.getPersistenceState());
-				assertEquals(PersistenceState.COMMITTED,
-						childCommitted.getPersistenceState());
-				assertEquals(PersistenceState.HOLLOW,
-						childHollow.getPersistenceState());
+			assertEquals(PersistenceState.COMMITTED, childNew.getPersistenceState());
+			assertEquals(PersistenceState.COMMITTED, childModified.getPersistenceState());
+			assertEquals(PersistenceState.COMMITTED, childCommitted.getPersistenceState());
+			assertEquals(PersistenceState.HOLLOW, childHollow.getPersistenceState());
 
-				ClientMtTable1 parentNew = (ClientMtTable1) clientContext
-						.getGraphManager().getNode(childNew.getObjectId());
-				final ClientMtTable1 parentModified = (ClientMtTable1) clientContext
-						.getGraphManager().getNode(childModified.getObjectId());
-				ClientMtTable1 parentCommitted = (ClientMtTable1) clientContext
-						.getGraphManager()
-						.getNode(childCommitted.getObjectId());
-				ClientMtTable1 parentHollow = (ClientMtTable1) clientContext
-						.getGraphManager().getNode(childHollow.getObjectId());
+			ClientMtTable1 parentNew = (ClientMtTable1) clientContext
+					.getGraphManager().getNode(childNew.getObjectId());
+			final ClientMtTable1 parentModified = (ClientMtTable1) clientContext
+					.getGraphManager().getNode(childModified.getObjectId());
+			ClientMtTable1 parentCommitted = (ClientMtTable1) clientContext
+					.getGraphManager()
+					.getNode(childCommitted.getObjectId());
+			ClientMtTable1 parentHollow = (ClientMtTable1) clientContext
+					.getGraphManager().getNode(childHollow.getObjectId());
 
-				assertNotNull(parentNew);
-				assertEquals(PersistenceState.NEW,
-						parentNew.getPersistenceState());
-				assertEquals("NNN", parentNew.getGlobalAttribute1());
+			assertNotNull(parentNew);
+			assertEquals(PersistenceState.NEW, parentNew.getPersistenceState());
+			assertEquals("NNN", parentNew.getGlobalAttribute1());
 
-				assertNotNull(parentModified);
-				assertEquals(PersistenceState.MODIFIED,
-						parentModified.getPersistenceState());
-				assertEquals("MMM", parentModified.getGlobalAttribute1());
+			assertNotNull(parentModified);
+			assertEquals(PersistenceState.MODIFIED, parentModified.getPersistenceState());
+			assertEquals("MMM", parentModified.getGlobalAttribute1());
 
-				assertNotNull(parentCommitted);
-				assertEquals(PersistenceState.COMMITTED,
-						parentCommitted.getPersistenceState());
+			assertNotNull(parentCommitted);
+			assertEquals(PersistenceState.COMMITTED, parentCommitted.getPersistenceState());
 
-				assertNotNull(parentHollow);
+			assertNotNull(parentHollow);
 
-				// check that arc changes got recorded in the parent context
-				GraphDiff diffs = clientContext.internalGraphManager()
-						.getDiffs();
+			// check that arc changes got recorded in the parent context
+			GraphDiff diffs = clientContext.internalGraphManager().getDiffs();
 
-				final int[] modifiedProperties = new int[1];
+			final int[] modifiedProperties = new int[1];
 
-				diffs.apply(new GraphChangeHandler() {
-
-					@Override
-					public void arcCreated(Object nodeId, Object targetNodeId,
-							Object arcId) {
-
-					}
+			diffs.apply(new GraphChangeHandler() {
 
-					@Override
-					public void arcDeleted(Object nodeId, Object targetNodeId,
-							Object arcId) {
-
-					}
-
-					@Override
-					public void nodeCreated(Object nodeId) {
+				@Override
+				public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) {
+				}
 
-					}
+				@Override
+				public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) {
+				}
 
-					@Override
-					public void nodeIdChanged(Object nodeId, Object newId) {
-					}
+				@Override
+				public void nodeCreated(Object nodeId) {
+				}
 
-					@Override
-					public void nodePropertyChanged(Object nodeId,
-							String property, Object oldValue, Object newValue) {
+				@Override
+				public void nodeIdChanged(Object nodeId, Object newId) {
+				}
 
-						if (nodeId.equals(parentModified.getObjectId())) {
-							modifiedProperties[0]++;
-						}
+				@Override
+				public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
+					if (nodeId.equals(parentModified.getObjectId())) {
+						modifiedProperties[0]++;
 					}
+				}
 
-					@Override
-					public void nodeRemoved(Object nodeId) {
-
-					}
-				});
+				@Override
+				public void nodeRemoved(Object nodeId) {
+				}
+			});
 
-				assertEquals(1, modifiedProperties[0]);
-			}
+			assertEquals(1, modifiedProperties[0]);
 		});
 	}
 
 	@Test
-	public void testCommitChangesToParentDeleted() throws Exception {
+	public void testCommitChangesToParentDeleted() {
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
@@ -454,8 +398,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		// make sure we fetch in predictable order
-		SelectQuery<ClientMtTable1> query = new SelectQuery<ClientMtTable1>(
-				ClientMtTable1.class);
+		SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
 		List<ClientMtTable1> objects = child.select(query);
 
 		assertEquals(4, objects.size());
@@ -473,11 +416,10 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		// * all modifications should be propagated to the parent
 		// * no actual commit should occur.
 
-		assertEquals(PersistenceState.TRANSIENT,
-				childDeleted.getPersistenceState());
+		assertEquals(PersistenceState.TRANSIENT, childDeleted.getPersistenceState());
 
-		ClientMtTable1 parentDeleted = (ClientMtTable1) clientContext
-				.getGraphManager().getNode(childDeleted.getObjectId());
+		ClientMtTable1 parentDeleted = (ClientMtTable1) clientContext.getGraphManager()
+				.getNode(childDeleted.getObjectId());
 
 		assertNotNull(parentDeleted);
 		assertEquals(PersistenceState.DELETED,
@@ -486,7 +428,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testCommitChanges() throws Exception {
+	public void testCommitChanges() {
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
 		clientContext.newObject(ClientMtTable1.class);
@@ -496,8 +438,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		// make sure we fetch in predictable order
-		SelectQuery<ClientMtTable1> query = new SelectQuery<ClientMtTable1>(
-				ClientMtTable1.class);
+		SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
 		List<ClientMtTable1> objects = child.select(query);
 
 		assertEquals(4, objects.size());
@@ -521,12 +462,9 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		child.commitChanges();
 
 		assertEquals(PersistenceState.COMMITTED, childNew.getPersistenceState());
-		assertEquals(PersistenceState.COMMITTED,
-				childModified.getPersistenceState());
-		assertEquals(PersistenceState.COMMITTED,
-				childCommitted.getPersistenceState());
-		assertEquals(PersistenceState.TRANSIENT,
-				childDeleted.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, childModified.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, childCommitted.getPersistenceState());
+		assertEquals(PersistenceState.TRANSIENT, childDeleted.getPersistenceState());
 		assertEquals(PersistenceState.HOLLOW, childHollow.getPersistenceState());
 
 		ClientMtTable1 parentNew = (ClientMtTable1) clientContext
@@ -541,26 +479,23 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 				.getGraphManager().getNode(childHollow.getObjectId());
 
 		assertNotNull(parentNew);
-		assertEquals(PersistenceState.COMMITTED,
-				parentNew.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, parentNew.getPersistenceState());
 		assertEquals("NNN", parentNew.getGlobalAttribute1());
 
 		assertNotNull(parentModified);
-		assertEquals(PersistenceState.COMMITTED,
-				parentModified.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, parentModified.getPersistenceState());
 		assertEquals("MMM", parentModified.getGlobalAttribute1());
 
 		assertNull("Deleted object should not be registered.", parentDeleted);
 
 		assertNotNull(parentCommitted);
-		assertEquals(PersistenceState.COMMITTED,
-				parentCommitted.getPersistenceState());
+		assertEquals(PersistenceState.COMMITTED, parentCommitted.getPersistenceState());
 
 		assertNotNull(parentHollow);
 	}
 
 	@Test
-	public void testAddRemove() throws Exception {
+	public void testAddRemove() {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		ClientMtTable1 a = child.newObject(ClientMtTable1.class);
@@ -585,7 +520,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testChangeRel() throws Exception {
+	public void testChangeRel() {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		ClientMtTable1 a = child.newObject(ClientMtTable1.class);
@@ -617,7 +552,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testCAY1183() throws Exception {
+	public void testCAY1183()  {
 		ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
 		clientContext.commitChanges();
 
@@ -639,15 +574,12 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	 * CAY1714
 	 */
 	@Test
-	public void testQueriesOnTemporaryObject() throws Exception {
-		ObjectContext clientContext = runtime
-				.newContext((DataChannel) this.clientContext);
+	public void testQueriesOnTemporaryObject() {
+		ObjectContext clientContext = runtime.newContext(this.clientContext);
 		ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
 
-		ObjectContext childContext = runtime
-				.newContext((DataChannel) clientContext);
-		ClientMtTable1 childMt = (ClientMtTable1) Cayenne.objectForPK(
-				childContext, parentMt.getObjectId());
+		ObjectContext childContext = runtime.newContext(clientContext);
+		ClientMtTable1 childMt = (ClientMtTable1) Cayenne.objectForPK(childContext, parentMt.getObjectId());
 		childMt.setGlobalAttribute1("1183");
 		ClientMtTable2 childMt2 = childContext.newObject(ClientMtTable2.class);
 		childMt2.setGlobalAttribute("1183");
@@ -659,7 +591,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testCAY1194() throws Exception {
+	public void testCAY1194() {
 		ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
 		ObjectContext child = runtime.newContext(clientContext);
 
@@ -685,7 +617,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 	}
 
 	@Test
-	public void testCommitChangesToParentOneToMany() throws Exception {
+	public void testCommitChangesToParentOneToMany() {
 		ObjectContext child = runtime.newContext(clientContext);
 
 		ClientMtTable1 master = child.newObject(ClientMtTable1.class);
@@ -712,14 +644,11 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 		final int[] newNodes = new int[1];
 
 		diffs.apply(new GraphChangeHandler() {
-
-			public void arcCreated(Object nodeId, Object targetNodeId,
-					Object arcId) {
+			public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) {
 				arcDiffs[0]++;
 			}
 
-			public void arcDeleted(Object nodeId, Object targetNodeId,
-					Object arcId) {
+			public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) {
 				arcDiffs[0]--;
 			}
 
@@ -730,8 +659,7 @@ public class NestedCayenneContextIT extends RemoteCayenneCase {
 			public void nodeIdChanged(Object nodeId, Object newId) {
 			}
 
-			public void nodePropertyChanged(Object nodeId, String property,
-					Object oldValue, Object newValue) {
+			public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
 			}
 
 			public void nodeRemoved(Object nodeId) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelIT.java b/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelIT.java
index 507d63d..62ecbe6 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelIT.java
@@ -43,7 +43,6 @@ import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.MockQuery;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
 import org.apache.cayenne.remote.QueryMessage;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.test.jdbc.TableHelper;
@@ -53,7 +52,6 @@ import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.testdo.mt.ClientMtTable3;
 import org.apache.cayenne.testdo.mt.MtTable1;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.client.ClientCase;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
@@ -98,7 +96,7 @@ public class ClientServerChannelIT extends ClientCase {
 		tMtTable3.setColumns("TABLE3_ID", "BINARY_COLUMN", "CHAR_COLUMN", "INT_COLUMN");
 	}
 
-	protected void createTwoMtTable1sAnd2sDataSet() throws Exception {
+	private void createTwoMtTable1sAnd2sDataSet() throws Exception {
 
 		tMtTable1.insert(1, "g1", "s1");
 		tMtTable1.insert(2, "g2", "s2");
@@ -108,7 +106,7 @@ public class ClientServerChannelIT extends ClientCase {
 	}
 
 	@Test
-	public void testGetEntityResolver() throws Exception {
+	public void testGetEntityResolver() {
 		EntityResolver resolver = clientServerChannel.getEntityResolver();
 		assertNotNull(resolver);
 		assertNull(resolver.getObjEntity(ClientMtTable1.class));
@@ -116,9 +114,9 @@ public class ClientServerChannelIT extends ClientCase {
 	}
 
 	@Test
-	public void testSynchronizeCommit() throws Exception {
+	public void testSynchronizeCommit() {
 
-		SelectQuery query = new SelectQuery(MtTable1.class);
+		SelectQuery<MtTable1> query = new SelectQuery<>(MtTable1.class);
 
 		// no changes...
 		clientServerChannel.onSync(serverContext, mock(GraphDiff.class), DataChannel.FLUSH_CASCADE_SYNC);
@@ -126,8 +124,9 @@ public class ClientServerChannelIT extends ClientCase {
 		assertEquals(0, serverContext.performQuery(query).size());
 
 		// introduce changes
-		clientServerChannel.onSync(serverContext, new NodeCreateOperation(new ObjectId("MtTable1")),
-				DataChannel.FLUSH_CASCADE_SYNC);
+		clientServerChannel.onSync(serverContext
+				, new NodeCreateOperation(new ObjectId("MtTable1"))
+				, DataChannel.FLUSH_CASCADE_SYNC);
 
 		assertEquals(1, serverContext.performQuery(query).size());
 	}
@@ -185,7 +184,7 @@ public class ClientServerChannelIT extends ClientCase {
 
 		tMtTable1.insert(65, "sub1", "xyz");
 
-		SelectQuery query = new SelectQuery(ClientMtTable1.class);
+		SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
 		QueryResponse response = clientServerChannel.onQuery(null, query);
 
 		assertNotNull(response);
@@ -225,24 +224,21 @@ public class ClientServerChannelIT extends ClientCase {
 	public void testOnQueryPrefetchingToMany() throws Exception {
 		createTwoMtTable1sAnd2sDataSet();
 
-		SelectQuery query = new SelectQuery(ClientMtTable1.class);
-		query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
-		query.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
+		SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
+		query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
+		query.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
 
 		final List<?> results = clientServerChannel.onQuery(null, query).firstList();
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			ClientMtTable1 o1 = (ClientMtTable1) results.get(0);
+			assertNull(o1.getObjectContext());
 
-			public void execute() {
-				ClientMtTable1 o1 = (ClientMtTable1) results.get(0);
-				assertNull(o1.getObjectContext());
+			List<ClientMtTable2> children1 = o1.getTable2Array();
 
-				List<ClientMtTable2> children1 = o1.getTable2Array();
-
-				assertEquals(2, children1.size());
-				for (ClientMtTable2 o : children1) {
-					assertNull(o.getObjectContext());
-				}
+			assertEquals(2, children1.size());
+			for (ClientMtTable2 o : children1) {
+				assertNull(o.getObjectContext());
 			}
 		});
 	}
@@ -251,24 +247,20 @@ public class ClientServerChannelIT extends ClientCase {
 	public void testOnQueryPrefetchingToManyEmpty() throws Exception {
 		createTwoMtTable1sAnd2sDataSet();
 
-		SelectQuery q = new SelectQuery(ClientMtTable1.class);
-		q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
-		q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
+		SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class);
+		q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
+		q.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
 
 		final List<?> results = clientServerChannel.onQuery(null, q).firstList();
 
-		queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-			public void execute() {
+		queryInterceptor.runWithQueriesBlocked(() -> {
+			ClientMtTable1 o2 = (ClientMtTable1) results.get(1);
+			assertNull(o2.getObjectContext());
 
-				ClientMtTable1 o2 = (ClientMtTable1) results.get(1);
-				assertNull(o2.getObjectContext());
-
-				List<?> children2 = o2.getTable2Array();
-				assertNotNull(children2);
-				assertFalse(((ValueHolder) children2).isFault());
-				assertEquals(0, children2.size());
-			}
+			List<?> children2 = o2.getTable2Array();
+			assertNotNull(children2);
+			assertFalse(((ValueHolder) children2).isFault());
+			assertEquals(0, children2.size());
 		});
 	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryIT.java b/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryIT.java
index d5afa0a..e809e35 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryIT.java
@@ -88,8 +88,8 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testPaginatedQueryServerCacheOverflow() throws Exception {
         createSevenMtTable1sDataSet();
 
-        SelectQuery query = new SelectQuery(ClientMtTable1.class);
-        query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
+        SelectQuery<ClientMtTable1> query = new SelectQuery<>(ClientMtTable1.class);
+        query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
         query.setPageSize(3);
 
         List<?> results = context.performQuery(query);
@@ -135,7 +135,7 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testSelectQueryClientClassRoot() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class);
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class);
         List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
@@ -146,7 +146,8 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testSelectQuerySimpleQualifier() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("globalAttribute1 = 'g1'"));
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class
+                , ExpressionFactory.exp("globalAttribute1 = 'g1'"));
         List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
@@ -158,7 +159,8 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testSelectQueryToManyRelationshipQualifier() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("table2Array.globalAttribute = 'g1'"));
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class
+                , ExpressionFactory.exp("table2Array.globalAttribute = 'g1'"));
         List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
@@ -170,7 +172,7 @@ public class ClientServerChannelQueryIT extends ClientCase {
         createTwoMtTable1sAnd2sDataSet();
 
         SelectQuery q = new SelectQuery("MtTable1");
-        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
+        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.asc());
         List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
@@ -183,7 +185,7 @@ public class ClientServerChannelQueryIT extends ClientCase {
         // result wasn't coincidental.
 
         q.clearOrderings();
-        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.DESCENDING);
+        q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1.desc());
         List<?> results1 = context.performQuery(q);
 
         assertEquals(2, results1.size());
@@ -197,8 +199,9 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testSelectQueryPrefetchToOne() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable2.class, ExpressionFactory.exp("globalAttribute = 'g1'"));
-        q.addPrefetch(ClientMtTable2.TABLE1_PROPERTY);
+        SelectQuery<ClientMtTable2> q = new SelectQuery<>(ClientMtTable2.class
+                , ExpressionFactory.exp("globalAttribute = 'g1'"));
+        q.addPrefetch(ClientMtTable2.TABLE1.disjoint());
         List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
@@ -219,8 +222,9 @@ public class ClientServerChannelQueryIT extends ClientCase {
     public void testSelectQueryPrefetchToMany() throws Exception {
         createTwoMtTable1sAnd2sDataSet();
 
-        SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("globalAttribute1 = 'g1'"));
-        q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
+        SelectQuery<ClientMtTable1> q = new SelectQuery<>(ClientMtTable1.class
+                , ExpressionFactory.exp("globalAttribute1 = 'g1'"));
+        q.addPrefetch(ClientMtTable1.TABLE2ARRAY.joint());
         List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());


Mime
View raw message