You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2014/11/02 08:10:24 UTC

[36/48] Installing Maven Failsafe Plugin

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryIT.java
new file mode 100644
index 0000000..37054c4
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryIT.java
@@ -0,0 +1,248 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Types;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextEJBQLSubqueryIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private UnitDbAdapter accessStackAdapter;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tArtist;
+    private TableHelper tPainting;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("PAINTING1");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "PAINTING_ID",
+                "ARTIST_ID",
+                "PAINTING_TITLE",
+                "ESTIMATED_PRICE").setColumnTypes(
+                Types.INTEGER,
+                Types.BIGINT,
+                Types.VARCHAR,
+                Types.DECIMAL);
+    }
+
+    private void createTwoArtistsFourPaintings() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tPainting.insert(33001, 33001, "P1", 3000);
+        tPainting.insert(33002, 33001, "P2", 4000);
+        tPainting.insert(33003, null, "P1", 5000);
+        tPainting.insert(33004, null, "P4", 6000);
+    }
+
+    public void testSubqueryNoQualifier() throws Exception {
+        if (!accessStackAdapter.supportsAllAnySome()) {
+            return;
+        }
+
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT DISTINCT p FROM Painting p"
+                + " WHERE p.estimatedPrice = ALL ("
+                + " SELECT MAX(p1.estimatedPrice) FROM Painting p1"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(1, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33004)));
+    }
+
+    public void testDifferentEntity() throws Exception {
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT a FROM Artist a"
+                + " WHERE EXISTS ("
+                + " SELECT DISTINCT p1.paintingTitle FROM Painting p1"
+                + " WHERE p1.toArtist = a"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(1, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(33001l));
+
+        assertTrue("" + objects.get(0), objects.get(0) instanceof Artist);
+    }
+
+    public void testExists() throws Exception {
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE EXISTS ("
+                + " SELECT DISTINCT p1.paintingTitle FROM Painting p1"
+                + " WHERE p1.paintingTitle = p.paintingTitle"
+                + " AND p.estimatedPrice <> p1.estimatedPrice"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(2, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33001)));
+        assertTrue(ids.contains(new Integer(33003)));
+    }
+
+    public void testAll() throws Exception {
+        if (!accessStackAdapter.supportsAllAnySome()) {
+            return;
+        }
+
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE p.estimatedPrice > ALL ("
+                + " SELECT p1.estimatedPrice FROM Painting p1"
+                + " WHERE p1.paintingTitle = 'P2'"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(2, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33003)));
+        assertTrue(ids.contains(new Integer(33004)));
+    }
+
+    public void testAny() throws Exception {
+        if (!accessStackAdapter.supportsAllAnySome()) {
+            return;
+        }
+
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE p.estimatedPrice > ANY ("
+                + " SELECT p1.estimatedPrice FROM Painting p1"
+                + " WHERE p1.paintingTitle = 'P1'"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(3, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33002)));
+        assertTrue(ids.contains(new Integer(33003)));
+        assertTrue(ids.contains(new Integer(33004)));
+    }
+
+    public void testSome() throws Exception {
+        if (!accessStackAdapter.supportsAllAnySome()) {
+            return;
+        }
+
+        createTwoArtistsFourPaintings();
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE p.estimatedPrice > SOME ("
+                + " SELECT p1.estimatedPrice FROM Painting p1"
+                + " WHERE p1.paintingTitle = 'P1'"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(3, objects.size());
+
+        Set<Object> ids = new HashSet<Object>();
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = Cayenne.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33002)));
+        assertTrue(ids.contains(new Integer(33003)));
+        assertTrue(ids.contains(new Integer(33004)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
deleted file mode 100644
index 4c686b9..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.access;
-
-import java.sql.Types;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.Persistent;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextEJBQLSubqueryTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private UnitDbAdapter accessStackAdapter;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper tArtist;
-    private TableHelper tPainting;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("PAINTING1");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "ARTIST_ID",
-                "PAINTING_TITLE",
-                "ESTIMATED_PRICE").setColumnTypes(
-                Types.INTEGER,
-                Types.BIGINT,
-                Types.VARCHAR,
-                Types.DECIMAL);
-    }
-
-    private void createTwoArtistsFourPaintings() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tPainting.insert(33001, 33001, "P1", 3000);
-        tPainting.insert(33002, 33001, "P2", 4000);
-        tPainting.insert(33003, null, "P1", 5000);
-        tPainting.insert(33004, null, "P4", 6000);
-    }
-
-    public void testSubqueryNoQualifier() throws Exception {
-        if (!accessStackAdapter.supportsAllAnySome()) {
-            return;
-        }
-
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT DISTINCT p FROM Painting p"
-                + " WHERE p.estimatedPrice = ALL ("
-                + " SELECT MAX(p1.estimatedPrice) FROM Painting p1"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(33004)));
-    }
-
-    public void testDifferentEntity() throws Exception {
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT a FROM Artist a"
-                + " WHERE EXISTS ("
-                + " SELECT DISTINCT p1.paintingTitle FROM Painting p1"
-                + " WHERE p1.toArtist = a"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(33001l));
-
-        assertTrue("" + objects.get(0), objects.get(0) instanceof Artist);
-    }
-
-    public void testExists() throws Exception {
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT p FROM Painting p"
-                + " WHERE EXISTS ("
-                + " SELECT DISTINCT p1.paintingTitle FROM Painting p1"
-                + " WHERE p1.paintingTitle = p.paintingTitle"
-                + " AND p.estimatedPrice <> p1.estimatedPrice"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(33001)));
-        assertTrue(ids.contains(new Integer(33003)));
-    }
-
-    public void testAll() throws Exception {
-        if (!accessStackAdapter.supportsAllAnySome()) {
-            return;
-        }
-
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT p FROM Painting p"
-                + " WHERE p.estimatedPrice > ALL ("
-                + " SELECT p1.estimatedPrice FROM Painting p1"
-                + " WHERE p1.paintingTitle = 'P2'"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(33003)));
-        assertTrue(ids.contains(new Integer(33004)));
-    }
-
-    public void testAny() throws Exception {
-        if (!accessStackAdapter.supportsAllAnySome()) {
-            return;
-        }
-
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT p FROM Painting p"
-                + " WHERE p.estimatedPrice > ANY ("
-                + " SELECT p1.estimatedPrice FROM Painting p1"
-                + " WHERE p1.paintingTitle = 'P1'"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(3, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(33002)));
-        assertTrue(ids.contains(new Integer(33003)));
-        assertTrue(ids.contains(new Integer(33004)));
-    }
-
-    public void testSome() throws Exception {
-        if (!accessStackAdapter.supportsAllAnySome()) {
-            return;
-        }
-
-        createTwoArtistsFourPaintings();
-
-        String ejbql = "SELECT p FROM Painting p"
-                + " WHERE p.estimatedPrice > SOME ("
-                + " SELECT p1.estimatedPrice FROM Painting p1"
-                + " WHERE p1.paintingTitle = 'P1'"
-                + ")";
-
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        List<?> objects = context.performQuery(query);
-        assertEquals(3, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(33002)));
-        assertTrue(ids.contains(new Integer(33003)));
-        assertTrue(ids.contains(new Integer(33004)));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateIT.java
new file mode 100644
index 0000000..a3ba28b
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateIT.java
@@ -0,0 +1,333 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.QueryResponse;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.BooleanTestEntity;
+import org.apache.cayenne.testdo.testmap.CompoundPkTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextEJBQLUpdateIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tArtist;
+    private TableHelper tPainting;
+    private TableHelper tCompoundPk;
+    private TableHelper tCompoundFk;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("BOOLEAN_TEST");
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+        dbHelper.deleteAll("COMPOUND_FK_TEST");
+        dbHelper.deleteAll("COMPOUND_PK_TEST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "PAINTING_ID",
+                "ARTIST_ID",
+                "PAINTING_TITLE",
+                "ESTIMATED_PRICE").setColumnTypes(
+                Types.INTEGER,
+                Types.BIGINT,
+                Types.VARCHAR,
+                Types.DECIMAL);
+
+        tCompoundPk = new TableHelper(dbHelper, "COMPOUND_PK_TEST");
+        tCompoundPk.setColumns("KEY1", "KEY2");
+
+        tCompoundFk = new TableHelper(dbHelper, "COMPOUND_FK_TEST");
+        tCompoundFk.setColumns("PKEY", "F_KEY1", "F_KEY2");
+    }
+
+    private void createThreeArtistsTwoPaintings() throws Exception {
+        tArtist.insert(33001, "AA1");
+        tArtist.insert(33002, "AA2");
+        tArtist.insert(33003, "BB1");
+        tPainting.insert(33001, 33001, "P1", 3000);
+        tPainting.insert(33002, 33002, "P2", 5000);
+    }
+
+    private void createTwoCompoundPKTwoFK() throws Exception {
+        tCompoundPk.insert("a1", "a2");
+        tCompoundPk.insert("b1", "b2");
+        tCompoundFk.insert(33001, "a1", "a2");
+        tCompoundFk.insert(33002, "b1", "b2");
+    }
+
+    public void testUpdateQualifier() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.paintingTitle is NULL or p.paintingTitle <> 'XX'");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX' WHERE p.paintingTitle = 'P1'";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(1, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(1l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierString() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.paintingTitle is NULL or p.paintingTitle <> 'XX'");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX'";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierNull() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.estimatedPrice is not null");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = NULL";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+    // This fails until we implement arithmetic exps
+
+    // public void testUpdateNoQualifierArithmeticExpression() throws Exception {
+    // createThreeArtistsTwoPaintings();
+    //
+    //
+    // EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+    // + "WHERE p.paintingTitle is NULL or p.estimatedPrice <= 5000");
+    //
+    // Object notUpdated = Cayenne.objectForQuery(context, check);
+    // assertEquals(new Long(2l), notUpdated);
+    //
+    // String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = p.estimatedPrice * 2";
+    // EJBQLQuery query = new EJBQLQuery(ejbql);
+    //
+    // QueryResponse result = context.performGenericQuery(query);
+    //
+    // int[] count = result.firstUpdateCount();
+    // assertNotNull(count);
+    // assertEquals(1, count.length);
+    // assertEquals(2, count[0]);
+    //
+    // notUpdated = Cayenne.objectForQuery(context, check);
+    // assertEquals(new Long(0l), notUpdated);
+    // }
+
+    public void testUpdateNoQualifierMultipleItems() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.estimatedPrice is NULL or p.estimatedPrice <> 1");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX', p.estimatedPrice = 1";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierDecimal() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.estimatedPrice is NULL or p.estimatedPrice <> 1.1");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = 1.1";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierBoolean() throws Exception {
+
+        BooleanTestEntity o1 = context.newObject(BooleanTestEntity.class);
+        o1.setBooleanColumn(Boolean.TRUE);
+
+        BooleanTestEntity o2 = context.newObject(BooleanTestEntity.class);
+        o2.setBooleanColumn(Boolean.FALSE);
+
+        BooleanTestEntity o3 = context.newObject(BooleanTestEntity.class);
+        o3.setBooleanColumn(Boolean.FALSE);
+
+        context.commitChanges();
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from BooleanTestEntity p "
+                + "WHERE p.booleanColumn = true");
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(1l), notUpdated);
+
+        String ejbql = "UPDATE BooleanTestEntity AS p SET p.booleanColumn = true";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(3, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(3l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierToOne() throws Exception {
+        createThreeArtistsTwoPaintings();
+
+        Artist object = Cayenne.objectForPK(context, Artist.class, 33003);
+
+        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
+                + "WHERE p.toArtist <> :artist");
+        check.setParameter("artist", object);
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(2l), notUpdated);
+
+        String ejbql = "UPDATE Painting AS p SET p.toArtist = :artist";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("artist", object);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+    public void testUpdateNoQualifierToOneCompoundPK() throws Exception {
+        createTwoCompoundPKTwoFK();
+
+        Map<String, String> key1 = new HashMap<String, String>();
+        key1.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "b1");
+        key1.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "b2");
+        CompoundPkTestEntity object = Cayenne.objectForPK(
+                context,
+                CompoundPkTestEntity.class,
+                key1);
+
+        EJBQLQuery check = new EJBQLQuery(
+                "select count(e) from CompoundFkTestEntity e WHERE e.toCompoundPk <> :param");
+        check.setParameter("param", object);
+
+        Object notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(1l), notUpdated);
+
+        String ejbql = "UPDATE CompoundFkTestEntity e SET e.toCompoundPk = :param";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("param", object);
+
+        QueryResponse result = context.performGenericQuery(query);
+
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(2, count[0]);
+
+        notUpdated = Cayenne.objectForQuery(context, check);
+        assertEquals(new Long(0l), notUpdated);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateTest.java
deleted file mode 100644
index b5b748c..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.access;
-
-import java.sql.Types;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.QueryResponse;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.BooleanTestEntity;
-import org.apache.cayenne.testdo.testmap.CompoundPkTestEntity;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextEJBQLUpdateTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper tArtist;
-    private TableHelper tPainting;
-    private TableHelper tCompoundPk;
-    private TableHelper tCompoundFk;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("BOOLEAN_TEST");
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-        dbHelper.deleteAll("COMPOUND_FK_TEST");
-        dbHelper.deleteAll("COMPOUND_PK_TEST");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "ARTIST_ID",
-                "PAINTING_TITLE",
-                "ESTIMATED_PRICE").setColumnTypes(
-                Types.INTEGER,
-                Types.BIGINT,
-                Types.VARCHAR,
-                Types.DECIMAL);
-
-        tCompoundPk = new TableHelper(dbHelper, "COMPOUND_PK_TEST");
-        tCompoundPk.setColumns("KEY1", "KEY2");
-
-        tCompoundFk = new TableHelper(dbHelper, "COMPOUND_FK_TEST");
-        tCompoundFk.setColumns("PKEY", "F_KEY1", "F_KEY2");
-    }
-
-    private void createThreeArtistsTwoPaintings() throws Exception {
-        tArtist.insert(33001, "AA1");
-        tArtist.insert(33002, "AA2");
-        tArtist.insert(33003, "BB1");
-        tPainting.insert(33001, 33001, "P1", 3000);
-        tPainting.insert(33002, 33002, "P2", 5000);
-    }
-
-    private void createTwoCompoundPKTwoFK() throws Exception {
-        tCompoundPk.insert("a1", "a2");
-        tCompoundPk.insert("b1", "b2");
-        tCompoundFk.insert(33001, "a1", "a2");
-        tCompoundFk.insert(33002, "b1", "b2");
-    }
-
-    public void testUpdateQualifier() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.paintingTitle is NULL or p.paintingTitle <> 'XX'");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX' WHERE p.paintingTitle = 'P1'";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(1, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(1l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierString() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.paintingTitle is NULL or p.paintingTitle <> 'XX'");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX'";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierNull() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.estimatedPrice is not null");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = NULL";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-    // This fails until we implement arithmetic exps
-
-    // public void testUpdateNoQualifierArithmeticExpression() throws Exception {
-    // createThreeArtistsTwoPaintings();
-    //
-    //
-    // EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-    // + "WHERE p.paintingTitle is NULL or p.estimatedPrice <= 5000");
-    //
-    // Object notUpdated = Cayenne.objectForQuery(context, check);
-    // assertEquals(new Long(2l), notUpdated);
-    //
-    // String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = p.estimatedPrice * 2";
-    // EJBQLQuery query = new EJBQLQuery(ejbql);
-    //
-    // QueryResponse result = context.performGenericQuery(query);
-    //
-    // int[] count = result.firstUpdateCount();
-    // assertNotNull(count);
-    // assertEquals(1, count.length);
-    // assertEquals(2, count[0]);
-    //
-    // notUpdated = Cayenne.objectForQuery(context, check);
-    // assertEquals(new Long(0l), notUpdated);
-    // }
-
-    public void testUpdateNoQualifierMultipleItems() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.estimatedPrice is NULL or p.estimatedPrice <> 1");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.paintingTitle = 'XX', p.estimatedPrice = 1";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierDecimal() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.estimatedPrice is NULL or p.estimatedPrice <> 1.1");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.estimatedPrice = 1.1";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierBoolean() throws Exception {
-
-        BooleanTestEntity o1 = context.newObject(BooleanTestEntity.class);
-        o1.setBooleanColumn(Boolean.TRUE);
-
-        BooleanTestEntity o2 = context.newObject(BooleanTestEntity.class);
-        o2.setBooleanColumn(Boolean.FALSE);
-
-        BooleanTestEntity o3 = context.newObject(BooleanTestEntity.class);
-        o3.setBooleanColumn(Boolean.FALSE);
-
-        context.commitChanges();
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from BooleanTestEntity p "
-                + "WHERE p.booleanColumn = true");
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(1l), notUpdated);
-
-        String ejbql = "UPDATE BooleanTestEntity AS p SET p.booleanColumn = true";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(3, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(3l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierToOne() throws Exception {
-        createThreeArtistsTwoPaintings();
-
-        Artist object = Cayenne.objectForPK(context, Artist.class, 33003);
-
-        EJBQLQuery check = new EJBQLQuery("select count(p) from Painting p "
-                + "WHERE p.toArtist <> :artist");
-        check.setParameter("artist", object);
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(2l), notUpdated);
-
-        String ejbql = "UPDATE Painting AS p SET p.toArtist = :artist";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        query.setParameter("artist", object);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-    public void testUpdateNoQualifierToOneCompoundPK() throws Exception {
-        createTwoCompoundPKTwoFK();
-
-        Map<String, String> key1 = new HashMap<String, String>();
-        key1.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "b1");
-        key1.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "b2");
-        CompoundPkTestEntity object = Cayenne.objectForPK(
-                context,
-                CompoundPkTestEntity.class,
-                key1);
-
-        EJBQLQuery check = new EJBQLQuery(
-                "select count(e) from CompoundFkTestEntity e WHERE e.toCompoundPk <> :param");
-        check.setParameter("param", object);
-
-        Object notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(1l), notUpdated);
-
-        String ejbql = "UPDATE CompoundFkTestEntity e SET e.toCompoundPk = :param";
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        query.setParameter("param", object);
-
-        QueryResponse result = context.performGenericQuery(query);
-
-        int[] count = result.firstUpdateCount();
-        assertNotNull(count);
-        assertEquals(1, count.length);
-        assertEquals(2, count[0]);
-
-        notUpdated = Cayenne.objectForQuery(context, check);
-        assertEquals(new Long(0l), notUpdated);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKIT.java
new file mode 100644
index 0000000..d8c3366
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKIT.java
@@ -0,0 +1,130 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.ObjectIdQuery;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.MeaningfulPKDep;
+import org.apache.cayenne.testdo.testmap.MeaningfulPKTest1;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextEntityWithMeaningfulPKIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MEANINGFUL_PK_DEP");
+        dbHelper.deleteAll("MEANINGFUL_PK_TEST1");
+    }
+
+    public void testInsertWithMeaningfulPK() throws Exception {
+        MeaningfulPKTest1 obj = context.newObject(MeaningfulPKTest1.class);
+        obj.setPkAttribute(1000);
+        obj.setDescr("aaa-aaa");
+        context.commitChanges();
+        ObjectIdQuery q = new ObjectIdQuery(new ObjectId(
+                "MeaningfulPKTest1",
+                MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN,
+                1000), true, ObjectIdQuery.CACHE_REFRESH);
+        assertEquals(1, context.performQuery(q).size());
+    }
+
+    public void testGeneratedKey() throws Exception {
+        MeaningfulPKTest1 obj = context.newObject(MeaningfulPKTest1.class);
+        obj.setDescr("aaa-aaa");
+        context.commitChanges();
+
+        assertNotNull(obj.getPkAttribute());
+        assertSame(obj, Cayenne.objectForPK(context, MeaningfulPKTest1.class, obj
+                .getPkAttribute()));
+
+        int id = Cayenne.intPKForObject(obj);
+
+        Map snapshot = context.getObjectStore().getDataRowCache().getCachedSnapshot(
+                obj.getObjectId());
+        assertNotNull(snapshot);
+        assertTrue(snapshot.containsKey(MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN));
+        assertEquals(new Integer(id), snapshot
+                .get(MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN));
+    }
+
+    public void testChangeKey() throws Exception {
+        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
+                .newObject("MeaningfulPKTest1");
+        obj.setPkAttribute(new Integer(1000));
+        obj.setDescr("aaa-aaa");
+        context.commitChanges();
+
+        obj.setPkAttribute(new Integer(2000));
+        context.commitChanges();
+
+        // assert that object id got fixed
+        ObjectId id = obj.getObjectId();
+        assertEquals(new Integer(2000), id.getIdSnapshot().get("PK_ATTRIBUTE"));
+    }
+
+    public void testToManyRelationshipWithMeaningfulPK1() throws Exception {
+        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
+                .newObject("MeaningfulPKTest1");
+        obj.setPkAttribute(new Integer(1000));
+        obj.setDescr("aaa-aaa");
+        context.commitChanges();
+
+        // must be able to resolve to-many relationship
+        ObjectContext context = runtime.newContext();
+        List objects = context.performQuery(new SelectQuery(MeaningfulPKTest1.class));
+        assertEquals(1, objects.size());
+        obj = (MeaningfulPKTest1) objects.get(0);
+        assertEquals(0, obj.getMeaningfulPKDepArray().size());
+    }
+
+    public void testToManyRelationshipWithMeaningfulPK2() throws Exception {
+        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
+                .newObject("MeaningfulPKTest1");
+        obj.setPkAttribute(new Integer(1000));
+        obj.setDescr("aaa-aaa");
+        context.commitChanges();
+
+        // must be able to set reverse relationship
+        MeaningfulPKDep dep = (MeaningfulPKDep) context.newObject("MeaningfulPKDep");
+        dep.setToMeaningfulPK(obj);
+        context.commitChanges();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKTest.java
deleted file mode 100644
index e107c7c..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextEntityWithMeaningfulPKTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.ObjectIdQuery;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.MeaningfulPKDep;
-import org.apache.cayenne.testdo.testmap.MeaningfulPKTest1;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextEntityWithMeaningfulPKTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("MEANINGFUL_PK_DEP");
-        dbHelper.deleteAll("MEANINGFUL_PK_TEST1");
-    }
-
-    public void testInsertWithMeaningfulPK() throws Exception {
-        MeaningfulPKTest1 obj = context.newObject(MeaningfulPKTest1.class);
-        obj.setPkAttribute(1000);
-        obj.setDescr("aaa-aaa");
-        context.commitChanges();
-        ObjectIdQuery q = new ObjectIdQuery(new ObjectId(
-                "MeaningfulPKTest1",
-                MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN,
-                1000), true, ObjectIdQuery.CACHE_REFRESH);
-        assertEquals(1, context.performQuery(q).size());
-    }
-
-    public void testGeneratedKey() throws Exception {
-        MeaningfulPKTest1 obj = context.newObject(MeaningfulPKTest1.class);
-        obj.setDescr("aaa-aaa");
-        context.commitChanges();
-
-        assertNotNull(obj.getPkAttribute());
-        assertSame(obj, Cayenne.objectForPK(context, MeaningfulPKTest1.class, obj
-                .getPkAttribute()));
-
-        int id = Cayenne.intPKForObject(obj);
-
-        Map snapshot = context.getObjectStore().getDataRowCache().getCachedSnapshot(
-                obj.getObjectId());
-        assertNotNull(snapshot);
-        assertTrue(snapshot.containsKey(MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN));
-        assertEquals(new Integer(id), snapshot
-                .get(MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN));
-    }
-
-    public void testChangeKey() throws Exception {
-        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
-                .newObject("MeaningfulPKTest1");
-        obj.setPkAttribute(new Integer(1000));
-        obj.setDescr("aaa-aaa");
-        context.commitChanges();
-
-        obj.setPkAttribute(new Integer(2000));
-        context.commitChanges();
-
-        // assert that object id got fixed
-        ObjectId id = obj.getObjectId();
-        assertEquals(new Integer(2000), id.getIdSnapshot().get("PK_ATTRIBUTE"));
-    }
-
-    public void testToManyRelationshipWithMeaningfulPK1() throws Exception {
-        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
-                .newObject("MeaningfulPKTest1");
-        obj.setPkAttribute(new Integer(1000));
-        obj.setDescr("aaa-aaa");
-        context.commitChanges();
-
-        // must be able to resolve to-many relationship
-        ObjectContext context = runtime.newContext();
-        List objects = context.performQuery(new SelectQuery(MeaningfulPKTest1.class));
-        assertEquals(1, objects.size());
-        obj = (MeaningfulPKTest1) objects.get(0);
-        assertEquals(0, obj.getMeaningfulPKDepArray().size());
-    }
-
-    public void testToManyRelationshipWithMeaningfulPK2() throws Exception {
-        MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
-                .newObject("MeaningfulPKTest1");
-        obj.setPkAttribute(new Integer(1000));
-        obj.setDescr("aaa-aaa");
-        context.commitChanges();
-
-        // must be able to set reverse relationship
-        MeaningfulPKDep dep = (MeaningfulPKDep) context.newObject("MeaningfulPKDep");
-        dep.setToMeaningfulPK(obj);
-        context.commitChanges();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsIT.java
new file mode 100644
index 0000000..9caaf2b
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsIT.java
@@ -0,0 +1,100 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.CapsStrategy;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.ExtendedTypeEntity;
+import org.apache.cayenne.testdo.testmap.StringET1;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.Arrays;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextExtendedTypeOperationsIT extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("EXTENDED_TYPE_TEST");
+    }
+
+    public void testStoreExtendedType() {
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
+        e1.setName(new StringET1("X"));
+        e1.getObjectContext().commitChanges();
+
+        SQLTemplate checkQ = new SQLTemplate(
+                ExtendedTypeEntity.class,
+                "SELECT * FROM EXTENDED_TYPE_TEST WHERE NAME = 'X'");
+        checkQ.setFetchingDataRows(true);
+        checkQ.setColumnNamesCapitalization(CapsStrategy.UPPER);
+        assertEquals(1, e1.getObjectContext().performQuery(checkQ).size());
+    }
+
+    public void testInExpressionExtendedTypeArray() {
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
+        e1.setName(new StringET1("X"));
+
+        ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
+        e2.setName(new StringET1("Y"));
+
+        ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
+        e3.setName(new StringET1("Z"));
+
+        e1.getObjectContext().commitChanges();
+
+        Expression in = ExpressionFactory.inExp(
+                ExtendedTypeEntity.NAME_PROPERTY,
+                new StringET1("X"),
+                new StringET1("Y"));
+        SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
+        assertEquals(2, e1.getObjectContext().performQuery(query).size());
+    }
+
+    public void testInExpressionExtendedTypeList() {
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
+        e1.setName(new StringET1("X"));
+
+        ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
+        e2.setName(new StringET1("Y"));
+
+        ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
+        e3.setName(new StringET1("Z"));
+
+        e1.getObjectContext().commitChanges();
+
+        Expression in = ExpressionFactory.inExp(ExtendedTypeEntity.NAME_PROPERTY, Arrays
+                .asList(new StringET1("X"), new StringET1("Y")));
+        SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
+        assertEquals(2, e1.getObjectContext().performQuery(query).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
deleted file mode 100644
index dcaba0a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.access;
-
-import java.util.Arrays;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.CapsStrategy;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.ExtendedTypeEntity;
-import org.apache.cayenne.testdo.testmap.StringET1;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextExtendedTypeOperationsTest extends ServerCase {
-
-    @Inject
-    protected ObjectContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("EXTENDED_TYPE_TEST");
-    }
-
-    public void testStoreExtendedType() {
-        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
-        e1.setName(new StringET1("X"));
-        e1.getObjectContext().commitChanges();
-
-        SQLTemplate checkQ = new SQLTemplate(
-                ExtendedTypeEntity.class,
-                "SELECT * FROM EXTENDED_TYPE_TEST WHERE NAME = 'X'");
-        checkQ.setFetchingDataRows(true);
-        checkQ.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        assertEquals(1, e1.getObjectContext().performQuery(checkQ).size());
-    }
-
-    public void testInExpressionExtendedTypeArray() {
-        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
-        e1.setName(new StringET1("X"));
-
-        ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
-        e2.setName(new StringET1("Y"));
-
-        ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
-        e3.setName(new StringET1("Z"));
-
-        e1.getObjectContext().commitChanges();
-
-        Expression in = ExpressionFactory.inExp(
-                ExtendedTypeEntity.NAME_PROPERTY,
-                new StringET1("X"),
-                new StringET1("Y"));
-        SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
-        assertEquals(2, e1.getObjectContext().performQuery(query).size());
-    }
-
-    public void testInExpressionExtendedTypeList() {
-        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
-        e1.setName(new StringET1("X"));
-
-        ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
-        e2.setName(new StringET1("Y"));
-
-        ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
-        e3.setName(new StringET1("Z"));
-
-        e1.getObjectContext().commitChanges();
-
-        Expression in = ExpressionFactory.inExp(ExtendedTypeEntity.NAME_PROPERTY, Arrays
-                .asList(new StringET1("X"), new StringET1("Y")));
-        SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
-        assertEquals(2, e1.getObjectContext().performQuery(query).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
new file mode 100644
index 0000000..1c6e13e
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
@@ -0,0 +1,421 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.DataObject;
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.dba.JdbcPkGenerator;
+import org.apache.cayenne.dba.PkGenerator;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Types;
+import java.util.Date;
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextExtrasIT extends ServerCase {
+
+    @Inject
+    protected DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected JdbcEventLogger logger;
+
+    @Inject
+    protected AdhocObjectFactory objectFactory;
+
+    protected TableHelper tArtist;
+    protected TableHelper tPainting;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("PAINTING1");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "PAINTING_ID",
+                "ARTIST_ID",
+                "PAINTING_TITLE",
+                "ESTIMATED_PRICE").setColumnTypes(
+                Types.INTEGER,
+                Types.BIGINT,
+                Types.VARCHAR,
+                Types.DECIMAL);
+    }
+
+    protected void createPhantomModificationDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+    }
+
+    protected void createPhantomModificationsValidateToOneDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tPainting.insert(33001, 33001, "P1", 3000);
+    }
+
+    protected void createValidateOnToManyChangeDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+    }
+
+    protected void createPhantomRelationshipModificationCommitDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tPainting.insert(33001, 33001, "P1", 3000);
+    }
+
+    public void testManualIdProcessingOnCommit() throws Exception {
+
+        Artist object = context.newObject(Artist.class);
+        object.setArtistName("ABC");
+        assertEquals(PersistenceState.NEW, object.getPersistenceState());
+
+        // do a manual ID substitution
+        ObjectId manualId = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 77777);
+        object.setObjectId(manualId);
+
+        context.commitChanges();
+
+        assertEquals(PersistenceState.COMMITTED, object.getPersistenceState());
+        assertSame(object, context.getGraphManager().getNode(manualId));
+        assertEquals(manualId, object.getObjectId());
+    }
+
+    public void testResolveFault() {
+
+        Artist o1 = context.newObject(Artist.class);
+        o1.setArtistName("a");
+        context.commitChanges();
+
+        context.invalidateObjects(o1);
+        assertEquals(PersistenceState.HOLLOW, o1.getPersistenceState());
+        assertNull(o1.readPropertyDirectly("artistName"));
+
+        context.prepareForAccess(o1, null, false);
+        assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+        assertEquals("a", o1.readPropertyDirectly("artistName"));
+    }
+
+    public void testResolveFaultFailure() {
+
+        Persistent o1 = context.findOrCreateObject(new ObjectId(
+                "Artist",
+                Artist.ARTIST_ID_PK_COLUMN,
+                234));
+
+        try {
+            context.prepareForAccess(o1, null, false);
+            fail("Must blow on non-existing fault.");
+        }
+        catch (CayenneRuntimeException ex) {
+
+        }
+    }
+
+    public void testUserProperties() {
+
+        assertNull(context.getUserProperty("ABC"));
+        Object object = new Object();
+
+        context.setUserProperty("ABC", object);
+        assertSame(object, context.getUserProperty("ABC"));
+    }
+
+    public void testHasChangesNew() {
+
+        assertTrue("No changes expected in context", !context.hasChanges());
+        context.newObject("Artist");
+        assertTrue(
+                "Object added to context, expected to report changes",
+                context.hasChanges());
+    }
+
+    public void testNewObject() {
+
+        Artist a1 = (Artist) context.newObject("Artist");
+        assertTrue(context.getGraphManager().registeredNodes().contains(a1));
+        assertTrue(context.newObjects().contains(a1));
+    }
+
+    public void testNewObjectWithClass() {
+
+        Artist a1 = context.newObject(Artist.class);
+        assertTrue(context.getGraphManager().registeredNodes().contains(a1));
+        assertTrue(context.newObjects().contains(a1));
+    }
+
+    public void testIdObjectFromDataRow() {
+
+        DataRow row = new DataRow(10);
+        row.put("ARTIST_ID", new Integer(100000));
+        DataObject obj = context.objectFromDataRow(Artist.class, row);
+        assertNotNull(obj);
+        assertTrue(context.getGraphManager().registeredNodes().contains(obj));
+        assertEquals(PersistenceState.HOLLOW, obj.getPersistenceState());
+
+        assertNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
+    }
+
+    public void testPartialObjectFromDataRow() {
+
+        DataRow row = new DataRow(10);
+        row.put("ARTIST_ID", new Integer(100001));
+        row.put("ARTIST_NAME", "ArtistXYZ");
+        DataObject obj = context.objectFromDataRow(Artist.class, row);
+        assertNotNull(obj);
+        assertTrue(context.getGraphManager().registeredNodes().contains(obj));
+        assertEquals(PersistenceState.HOLLOW, obj.getPersistenceState());
+        assertNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
+    }
+
+    public void testFullObjectFromDataRow() {
+
+        DataRow row = new DataRow(10);
+        row.put("ARTIST_ID", new Integer(123456));
+        row.put("ARTIST_NAME", "ArtistXYZ");
+        row.put("DATE_OF_BIRTH", new Date());
+        Artist obj = context.objectFromDataRow(Artist.class, row);
+
+        assertTrue(context.getGraphManager().registeredNodes().contains(obj));
+        assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
+        assertNotNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
+        assertEquals("ArtistXYZ", obj.getArtistName());
+    }
+
+    public void testCommitChangesError() {
+
+        DataDomain domain = context.getParentDataDomain();
+
+        // setup mockup PK generator that will blow on PK request
+        // to emulate an exception
+        JdbcAdapter jdbcAdapter = objectFactory.newInstance(
+                JdbcAdapter.class,
+                JdbcAdapter.class.getName());
+        PkGenerator newGenerator = new JdbcPkGenerator(jdbcAdapter) {
+
+            @Override
+            public Object generatePk(DataNode node, DbAttribute pk) throws Exception {
+                throw new CayenneRuntimeException("Intentional");
+            }
+        };
+
+        PkGenerator oldGenerator = domain
+                .getDataNodes()
+                .iterator()
+                .next()
+                .getAdapter()
+                .getPkGenerator();
+        JdbcAdapter adapter = (JdbcAdapter) domain
+                .getDataNodes()
+                .iterator()
+                .next()
+                .getAdapter();
+
+        adapter.setPkGenerator(newGenerator);
+        try {
+            Artist newArtist = context.newObject(Artist.class);
+            newArtist.setArtistName("aaa");
+            context.commitChanges();
+            fail("Exception expected but not thrown due to missing PK generation routine.");
+        }
+        catch (CayenneRuntimeException ex) {
+            // exception expected
+        }
+        finally {
+            adapter.setPkGenerator(oldGenerator);
+        }
+    }
+
+    /**
+     * Testing behavior of Cayenne when a database exception is thrown in SELECT query.
+     */
+    public void testSelectException() {
+
+        SQLTemplate q = new SQLTemplate(Artist.class, "SELECT * FROM NON_EXISTENT_TABLE");
+
+        try {
+            context.performGenericQuery(q);
+            fail("Query was invalid and was supposed to fail.");
+        }
+        catch (RuntimeException ex) {
+            // exception expected
+        }
+
+    }
+
+    public void testEntityResolver() {
+        assertNotNull(context.getEntityResolver());
+    }
+
+    public void testPhantomModificationsValidate() throws Exception {
+
+        createPhantomModificationDataSet();
+
+        List<?> objects = context.performQuery(new SelectQuery(Artist.class));
+        Artist a1 = (Artist) objects.get(0);
+        Artist a2 = (Artist) objects.get(1);
+
+        a1.setArtistName(a1.getArtistName());
+        a1.resetValidationFlags();
+        a2.resetValidationFlags();
+        context.commitChanges();
+
+        assertFalse(a1.isValidateForSaveCalled());
+        assertFalse(a2.isValidateForSaveCalled());
+
+        // "phantom" modification - the property is really unchanged
+        a1.setArtistName(a1.getArtistName());
+
+        // some other unrelated object modification caused phantom modification to be
+        // committed as well...
+        // (see CAY-355)
+        a2.setArtistName(a2.getArtistName() + "_x");
+
+        a1.resetValidationFlags();
+        a2.resetValidationFlags();
+        context.commitChanges();
+
+        assertTrue(a2.isValidateForSaveCalled());
+        assertFalse(a1.isValidateForSaveCalled());
+    }
+
+    public void testPhantomModificationsValidateToOne() throws Exception {
+
+        createPhantomModificationsValidateToOneDataSet();
+
+        List<?> objects = context.performQuery(new SelectQuery(Painting.class));
+        Painting p1 = (Painting) objects.get(0);
+
+        p1.setPaintingTitle(p1.getPaintingTitle());
+        p1.resetValidationFlags();
+        context.commitChanges();
+
+        assertFalse(
+                "To-one relationship presence caused incorrect validation call.",
+                p1.isValidateForSaveCalled());
+    }
+
+    public void testValidateOnToManyChange() throws Exception {
+
+        createValidateOnToManyChangeDataSet();
+
+        List<?> objects = context.performQuery(new SelectQuery(Artist.class));
+        Artist a1 = (Artist) objects.get(0);
+
+        Painting p1 = context.newObject(Painting.class);
+        p1.setPaintingTitle("XXX");
+        a1.addToPaintingArray(p1);
+        a1.resetValidationFlags();
+        context.commitChanges();
+
+        assertFalse(a1.isValidateForSaveCalled());
+    }
+
+    public void testPhantomAttributeModificationCommit() throws Exception {
+
+        createPhantomModificationDataSet();
+
+        List<?> objects = context.performQuery(new SelectQuery(Artist.class));
+        Artist a1 = (Artist) objects.get(0);
+
+        String oldName = a1.getArtistName();
+
+        a1.setArtistName(oldName + ".mod");
+        a1.setArtistName(oldName);
+
+        context.commitChanges();
+        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
+    }
+
+    public void testPhantomRelationshipModificationCommit() throws Exception {
+
+        createPhantomRelationshipModificationCommitDataSet();
+
+        SelectQuery query = new SelectQuery(Painting.class);
+        List<?> objects = context.performQuery(query);
+        assertEquals(1, objects.size());
+
+        Painting p1 = (Painting) objects.get(0);
+
+        Artist oldArtist = p1.getToArtist();
+        Artist newArtist = Cayenne.objectForPK(context, Artist.class, 33002);
+
+        assertNotSame(oldArtist, newArtist);
+
+        p1.setToArtist(newArtist);
+        p1.setToArtist(oldArtist);
+
+        context.commitChanges();
+
+        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, oldArtist.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, newArtist.getPersistenceState());
+    }
+
+    public void testPhantomRelationshipModificationValidate() throws Exception {
+
+        createPhantomRelationshipModificationCommitDataSet();
+
+        SelectQuery query = new SelectQuery(Painting.class);
+        List<?> objects = context.performQuery(query);
+        assertEquals(1, objects.size());
+
+        Painting p1 = (Painting) objects.get(0);
+
+        Artist oldArtist = p1.getToArtist();
+        Artist newArtist = Cayenne.objectForPK(context, Artist.class, 33002);
+
+        assertNotSame(oldArtist, newArtist);
+
+        p1.setToArtist(newArtist);
+        p1.setToArtist(oldArtist);
+
+        p1.resetValidationFlags();
+        context.commitChanges();
+        assertFalse(p1.isValidateForSaveCalled());
+    }
+}