ArchiveOrangemail archive

commits.openjpa.apache.org


(List home) (Recent threads) (2 other Apache OpenJPA lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe address with "subscribe" in the subject line, or visit the list's homepage here.
  • Low traffic list: less than 3 messages per day
  • This list contains about 9,455 messages, beginning Jun 2007
  • 0 messages added yesterday
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

svn commit: r627979 [38/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-per...

pcl1203067506Fri, 15 Feb 2008 09:25:06 +0000 (UTC)
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryResults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryResults.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryResults.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,625 @@
+/*
+ * 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.openjpa.persistence.query;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest2;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest3;
+import org.apache.openjpa.persistence.Extent;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.apache.openjpa.persistence.jdbc.FetchMode;
+import org.apache.openjpa.persistence.jdbc.JDBCFetchPlan;
+
+/**
+ * Test that ResultList objects behaver correctly.
+ *
+ * @author Marc Prud'hommeaux
+ */
+public class TestQueryResults extends BaseQueryTest {
+
+    public TestQueryResults(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        deleteAll(RuntimeTest1.class);
+
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        em.persist(new RuntimeTest1("TestQueryResults1", 10));
+        em.persist(new RuntimeTest1("TestQueryResults3", 10));
+        em.persist(new RuntimeTest1("TestQueryResults5", 10));
+        em.persist(new RuntimeTest3("TestQueryResults2", 10));
+        em.persist(new RuntimeTest3("TestQueryResults4", 10));
+        em.persist(new RuntimeTest3("TestQueryResults6", 10));
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testQueryIteratorsReturnFalseForClosedQuery() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery("SELECT o FROM RuntimeTest1 o");
+        List c = q.getResultList();
+        Iterator i = c.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+
+        if (i.hasNext())
+            fail("Iterator obtained from Query should return false "
+                + "for hasNext() after Query has been closed");
+    }
+
+    public void testQueryIteratorsThrowExceptionForClosedQuery() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery("SELECT o FROM RuntimeTest1 o");
+        List c = q.getResultList();
+        Iterator i = c.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+
+        try {
+            i.next();
+            fail("Iterator.next() should have thrown Exception "
+                + "after query.closeAll() was called");
+        }
+        catch (Exception e) {
+            //
+        }
+    }
+
+    public void testLazyQueryIteratorsReturnFalseForClosedem() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        String query = "SELECT o FROM RuntimeTest1 o";
+        OpenJPAQuery q = em.createQuery(query);
+        q.getFetchPlan().setFetchBatchSize(5);
+        List c = q.getResultList();
+
+        Iterator i = c.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        endTx(em);
+        endEm(em);
+
+        if (i.hasNext())
+            fail("Lazy result iterator obtained from Query should return "
+                + "false for hasNext() after em has been closed");
+    }
+
+    public void testEagerQueryIteratorsWorkForClosedem() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        String query = "SELECT o FROM RuntimeTest1 o";
+        OpenJPAQuery q = em.createQuery(query);
+        q.getFetchPlan().setFetchBatchSize(-1);
+
+        List c = q.getResultList();
+
+        Iterator i = c.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        endTx(em);
+        endEm(em);
+
+        if (!i.hasNext())
+            fail("Eager result iterator obtained from Query should return "
+                + "true for hasNext() after em has been closed");
+    }
+
+    public void testQueryResultIsList() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        String query = "SELECT o FROM RuntimeTest1 o";
+
+        Collection c = (Collection) em.createQuery(query).getResultList();
+        if (!(c instanceof List))
+            fail("Collection (" + c.getClass() + ") should have "
+                + "been a List instance");
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testQueryResultSizeIsCorrect() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        em.persist(new RuntimeTest2("TestQueryResults1", 10));
+        endTx(em);
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        String query =
+            "SELECT r FROM RuntimeTest2 r WHERE r.stringField = \'TestQueryResults1\'";
+        List c = em.createQuery(query).getResultList();
+
+        assertEquals(1, c.size());
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testExtentIteratorsReturnFalseForClosedExtent() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        Extent extent = em.createExtent(RuntimeTest1.class, true);
+
+        Iterator i = extent.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        extent.closeAll();
+
+        if (i.hasNext())
+            fail("Iterator obtained from Extent should return false "
+                + "for hasNext() after Extent has been closed");
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testExtentIteratorsThrowExceptionForClosedExtent() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        Extent extent = em.createExtent(RuntimeTest1.class, true);
+
+        Iterator i = extent.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        extent.closeAll();
+
+        try {
+            i.next();
+            fail("Iterator.next() should have thrown Exception "
+                + "after Extent.closeAll() was called");
+        } catch (Exception e) {
+            // this is a *good* thing.
+        }
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testExtentIteratorsReturnFalseForClosedem() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        Extent extent = em.createExtent(RuntimeTest1.class, true);
+        Iterator i = extent.iterator();
+        if (!(i.hasNext()))
+            fail("Iterator should have had next()");
+        endTx(em);
+        endEm(em);
+
+        if (i.hasNext())
+            fail("Iterator obtained from Extent should return false "
+                + "for hasNext() after em has been closed");
+    }
+
+    public void testUniqueReturnsSingleResult() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        String query =
+            "SELECT DISTINCT r FROM RuntimeTest1 r WHERE r.stringField = \'TestQueryResults1\'";
+        Object obj = em.createQuery(query).getSingleResult();
+
+        assertTrue(obj instanceof RuntimeTest1);
+
+        query =
+            "SELECT DISTINCT r FROM RuntimeTest1 r WHERE r.stringField = \'xxxx\'";
+        OpenJPAQuery q = em.createQuery(query);
+        List l = q.getResultList();
+        assertNotNull(
+            "expecting l to be null since there is no RuntimeTest1 instance with stringfield=xxxx",
+            l);
+
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testUniqueThrowsExceptionIfMultipleResults() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        String query = "SELECT DISTINCT r FROM RuntimeTest1 r";
+        OpenJPAQuery q = em.createQuery(query);
+
+        try {
+            Object l = q.getSingleResult();
+            fail("Unique query matched multiple results.");
+        }
+        catch (Exception jue) {
+        }
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testImpossibleRangeReturnsEmptyList() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        String query = "SELECT r FROM RuntimeTest1 r";
+        OpenJPAQuery q = em.createQuery(query);
+        q.setFirstResult(2);
+        q.setMaxResults(0);
+
+        List results = q.getResultList();
+
+        assertEquals(0, results.size());
+        assertFalse(results.iterator().hasNext());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testImpossibleUniqueRangeReturnsNull() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT DISTINCT r FROM RuntimeTest1 r WHERE r.stringField = \'TestQueryResults1\'");
+        q.setFirstResult(2);
+        q.setMaxResults(0);
+        assertTrue(
+            "resultlist is not null its size is: " + q.getResultList().size(),
+            q.getResultList().isEmpty());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testSingleResultUniqueRange() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT DISTINCT r FROM RuntimeTest1 r WHERE r.stringField = \'TestQueryResults1\'");
+        q.setFirstResult(1);
+        q.setMaxResults(1000000);
+
+        assertTrue("resultlist is not empty", (q.getResultList()).isEmpty());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testMultiResultUniqueRange() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT DISTINCT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setFirstResult(1);
+        q.setMaxResults(2);
+
+        assertEquals("TestQueryResults2",
+            ((RuntimeTest1) q.getResultList().get(0)).getStringField());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    /* This test is being commented because it was supposed to be a converted test complementing the original JDO test
+      * which uses the setUnique() method available in JDO Query. OpenJPAQuery does not have such a method and hence this test
+      * does not make sense.
+      public void testUniqueThrowsExceptionIfNonUniqueRange()
+     {
+         OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+         startTx(em);
+
+         OpenJPAQuery q = em.createQuery("SELECT DISTINCT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+         q.setFirstResult(1);
+         q.setMaxResults(3);
+
+         try
+         {
+             q.getResultList();
+             fail("Unique allowed non-unique range.");
+         }
+         catch (Exception jue)
+         {
+         }
+         q.closeAll();
+         endTx(em);
+         endEm(em);
+     }
+     */
+    public void testFullRange() {
+        try {
+            OpenJPAEntityManager em =
+                (OpenJPAEntityManager) currentEntityManager();
+            startTx(em);
+
+            OpenJPAQuery q = em.createQuery(
+                "SELECT r FROM RuntimeTest1 ORDER BY r.stringField ASC");
+            q.setSubclasses(false);
+            q.setFirstResult(0);
+            Long l = new Long(Long.MAX_VALUE);
+            q.setMaxResults(l.intValue());
+
+            List res = (List) q.getResultList();
+            assertEquals(3, res.size());
+            for (int i = 0; i < res.size(); i++)
+                assertEquals("TestQueryResults" + (i * 2 + 1),
+                    ((RuntimeTest1) res.get(i)).getStringField());
+            q.closeAll();
+            endTx(em);
+            endEm(em);
+        }
+        catch (Exception uoe) {
+            //FIXME:AFAM -- Figure out JPA Equivalence of createExtent(class, false) ie how to restrict the query result to the base entity and
+            //not the subclasses
+        }
+    }
+
+    public void testFullRangeSubs() {
+        try {
+            OpenJPAEntityManager em =
+                (OpenJPAEntityManager) currentEntityManager();
+            startTx(em);
+
+            OpenJPAQuery q = em.createQuery(
+                "SELECT r FROM RuntimeTest1 ORDER BY r.stringField ASC");
+            q.setFirstResult(0);
+            Long l = new Long(Long.MAX_VALUE);
+            q.setMaxResults(l.intValue());
+
+            List res = (List) q.getResultList();
+            assertEquals(6, res.size());
+            for (int i = 0; i < res.size(); i++)
+                assertEquals("TestQueryResults" + (i + 1),
+                    ((RuntimeTest1) res.get(i)).getStringField());
+            q.closeAll();
+            endTx(em);
+            endEm(em);
+        }
+        catch (Exception uoe) {
+        }
+    }
+
+    public void testBeginRange() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setSubclasses(false);
+        for (int i = 0; i < 4; i++) {
+            q.setFirstResult(i);
+            q.setMaxResults(100000);
+
+            List res = (List) q.getResultList();
+            assertEquals("they are not equal", 3 - i, res.size());
+            int idx = 0;
+
+            // try both random acess and iteration
+            for (int j = 0; j < res.size(); j++)
+                assertEquals("TestQueryResults" + (j * 2 + 1 + i * 2),
+                    (((RuntimeTest1) res.get(j)).getStringField()));
+            for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+                assertEquals("TestQueryResults" + (idx * 2 + 1 + i * 2),
+                    ((RuntimeTest1) itr.next()).getStringField());
+        }
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testBeginRangeSubs() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+
+        for (int i = 0; i < 7; i++) {
+            q.setFirstResult(i);
+            Long l = new Long(Long.MAX_VALUE);
+            q.setMaxResults(100000);
+
+            List res = (List) q.getResultList();
+            assertEquals(6 - i, res.size());
+            int idx = 0;
+
+            // try both random acess and iteration
+            for (int j = 0; j < res.size(); j++)
+                assertEquals("TestQueryResults" + (j + 1 + i),
+                    ((RuntimeTest1) res.get(j)).getStringField());
+            for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+                assertEquals("TestQueryResults" + (idx + 1 + i),
+                    ((RuntimeTest1) itr.next()).getStringField());
+        }
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testEndRange() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setSubclasses(false);
+
+        for (int i = 0; i < 4; i++) {
+            q.setFirstResult(0);
+            q.setMaxResults(i);
+
+            List res = (List) q.getResultList();
+            assertEquals(i, res.size());
+            int idx = 0;
+
+            // try both random acess and iteration
+            for (int j = 0; j < res.size(); j++)
+                assertEquals("TestQueryResults" + (j * 2 + 1),
+                    ((RuntimeTest1) res.get(j)).getStringField());
+            for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+                assertEquals("TestQueryResults" + (idx * 2 + 1),
+                    ((RuntimeTest1) itr.next()).getStringField());
+        }
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testEndRangeSubs() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+
+        for (int i = 0; i < 7; i++) {
+            q.setFirstResult(0);
+            q.setMaxResults(i);
+            List res = (List) q.getResultList();
+            assertEquals(i, res.size());
+            int idx = 0;
+
+            // try both random acess and iteration
+            for (int j = 0; j < res.size(); j++)
+                assertEquals("TestQueryResults" + (j + 1),
+                    ((RuntimeTest1) res.get(j)).getStringField());
+            for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+                assertEquals("TestQueryResults" + (idx + 1),
+                    ((RuntimeTest1) itr.next()).getStringField());
+        }
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testMidRange() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setSubclasses(false);
+
+        q.setFirstResult(1);
+        q.setMaxResults(3);
+        List res = (List) q.getResultList();
+        assertEquals(2, res.size());
+        for (int i = 0; i < res.size(); i++)
+            assertEquals("TestQueryResults" + (i * 2 + 1 + 2),
+                ((RuntimeTest1) res.get(i)).getStringField());
+        int idx = 0;
+        for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+            assertEquals("TestQueryResults" + (idx * 2 + 1 + 2),
+                ((RuntimeTest1) itr.next()).getStringField());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testMidRangeSubs() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setFirstResult(1);
+        q.setMaxResults(3);
+
+        List res = (List) q.getResultList();
+        assertEquals(3, res.size());
+        for (int i = 0; i < res.size(); i++)
+            assertEquals("TestQueryResults" + (i + 1 + 1),
+                ((RuntimeTest1) res.get(i)).getStringField());
+        int idx = 0;
+        for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
+            assertEquals("TestQueryResults" + (idx + 1 + 1),
+                ((RuntimeTest1) itr.next()).getStringField());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testPessimisticOrderedRange() {
+        // test to make sure whatever machinations we do to get a range doesn't
+        // interfere with FOR UPDATE
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        OpenJPAQuery q = em.createQuery(
+            "SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
+        q.setSubclasses(false);
+        q.setFirstResult(0);
+        q.setMaxResults(2);
+
+        ((JDBCFetchPlan) q.getFetchPlan()).setEagerFetchMode(FetchMode.NONE);
+
+        List res = (List) q.getResultList();
+        assertEquals(2, res.size());
+        assertEquals("TestQueryResults1",
+            ((RuntimeTest1) res.get(0)).getStringField());
+        assertEquals("TestQueryResults3",
+            ((RuntimeTest1) res.get(1)).getStringField());
+        q.closeAll();
+        endTx(em);
+        endEm(em);
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQuotedNumbersInFilters2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQuotedNumbersInFilters2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQuotedNumbersInFilters2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,198 @@
+/*
+ * TestQuotedNumbersInFilters.java
+ *
+ * Created on October 18, 2006, 2:29 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+/*
+ * 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.openjpa.persistence.query;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import javax.persistence.Query;
+
+
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+public class TestQuotedNumbersInFilters2 extends BaseQueryTest {
+
+    public TestQuotedNumbersInFilters2(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+        deleteAll(RuntimeTest1.class);
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+        pm.persist(new RuntimeTest1("foo", 3));
+        pm.persist(new RuntimeTest1("bar", 15));
+        pm.persist(new RuntimeTest1("baz", -8));
+        pm.persist(new RuntimeTest1("baz2", 45)); // 45 is '-'
+        pm.persist(new RuntimeTest1("3", (int) '4'));
+        endTx(pm);
+        endEm(pm);
+
+        // make sure everything is working as expected for the base case.
+        assertEquals(1, helper("intField = -8"));
+        assertEquals(1, helper("intField = 15"));
+        assertEquals(1, helper("intField = 3"));
+        assertEquals(0, helper("intField = 51")); // the int value of '3'
+        assertEquals(0, helper("intField = 4"));
+        assertEquals(1, helper("intField = 52")); // the int value of '4'
+        assertEquals(1, helper("stringField = \'foo\'"));
+        assertEquals(1, helper("stringField = \'bar\'"));
+    }
+
+    public void testUnquotedNumbersWithExtraPrecision() {
+        assertEquals(1, helper("intField = 15"));
+        assertEquals(1, helper("intField = -8"));
+        assertEquals(1, helper("intField = 3"));
+        assertEquals(1, helper("intField = 45"));
+
+//    try {
+//        // test without casting ... some DBs don't like this
+////        assertEquals(1, helper("intField = 15.0"));
+////        assertEquals(1, helper("intField = -8.0"));
+//        assertEquals(1, helper("intField = 3.0"));
+//        assertEquals(1, helper("intField = 45.0"));
+//    } catch (Exception jdoe) {
+//        bug(AbstractTestCase.Platform.HYPERSONIC, 414, jdoe,
+//            "Some databases require explicit casts");
+//    }
+    }
+
+    public void testSingleQuotedStrings() {
+        assertEquals(1, helper("stringField = 'foo'"));
+        assertEquals(1, helper("stringField = '3'"));
+    }
+
+    public void testDoubleQuotedStrings() {
+        assertEquals(1, helper("stringField = \'foo\'"));
+        assertEquals(1, helper("stringField = \'3\'"));
+    }
+
+    /**
+     * Kodo 3.1 and prior treated single-quoted numbers as character literals,
+     * to the degree that prepared statement setInt() calls were made.
+     * Only the first digit of multiple-digit single-quoted numbers was used.
+     * FIX ME: aokeke - commenting this --> applies to kodo 3.1 and prior
+     */
+    public void testKodo31SingleQuotedMultipleCharacterBehavior() {
+        assertEquals(0, helper31("intField = '15'", true)); // looks like '1'
+        assertEquals(0, helper31("intField = '52'", true)); // looks like '5'
+        assertEquals(1, helper31("intField = '49'", true)); // looks like '4'
+        assertEquals(1, helper31("intField = '-8'", true)); // looks like '-'
+
+        assertEquals(0, helper31("intField = '15'", false));
+        assertEquals(0, helper31("intField = '52'", false));
+    }
+
+    /**
+     * Kodo 3.1 and prior did not match negative numbers of different types
+     * in in-mem queries.
+     */
+    public void testKodo31UnquotedInMemBehavior() {
+        assertEquals(1, helper31("intField = 3", false));
+        assertEquals(1, helper31("intField = -8", false));
+        assertEquals(1, helper31("intField = 15", false));
+        assertEquals(1, helper31("intField = 45", false));
+    }
+
+    public void testKodo31UnquotedDatastoreBehavior() {
+        assertEquals(1, helper31("intField = 3", false));
+        assertEquals(1, helper31("intField = -8", false));
+        assertEquals(1, helper31("intField = 15", false));
+        assertEquals(1, helper31("intField = 45", false));
+    }
+
+    /**
+     * Returns the # of matches to the query.
+     */
+    private long helper(String filter) {
+        return helper(filter, false);
+    }
+
+    /**
+     * Returns the # of matches to the query. Returns -1 if shouldFail
+     * is true and the query raised an exception in both in-mem and datastore
+     * queries.
+     */
+    private long helper(String filter, boolean shouldFail) {
+        OpenJPAEntityManager pm = getPM();
+
+        OpenJPAQuery q =
+            pm.createQuery("SELECT r FROM RuntimeTest1 r WHERE r." + filter);
+
+        long datastore = getResults(q, shouldFail);
+
+        q.setCandidateCollection((Collection) q.getResultList());
+        long inmem = getResults(q, shouldFail);
+
+        if (datastore != inmem)
+            fail("datastore query returned " + datastore + " values; " +
+                "inmem query returned " + inmem);
+
+        endEm(pm);
+        return datastore;
+    }
+
+    /**
+     * Returns the # of matches to the query. Performs the query in datastore
+     * or memory as appropriate.
+     */
+    private long helper31(String filter, boolean datastore) {
+        Map props = new HashMap();
+        props.put("openjpa.Compatibility", "QuotedNumbersInQueries=true");
+        OpenJPAEntityManager pm = getEmf(props).createEntityManager();
+
+        try {
+            OpenJPAQuery q = pm.createQuery(
+                "SELECT r FROM RuntimeTest1 r WHERE r." + filter);
+
+            if (!datastore)
+                q.setCandidateCollection((Collection) q.getResultList());
+            return getResults(q, false);
+        }
+        finally {
+            endEm(pm);
+        }
+    }
+
+    private long getResults(Query q, boolean shouldFail) {
+        try {
+
+            Integer result = new Integer(q.getResultList().size());
+            if (shouldFail) {
+                fail("should have failed");
+            }
+
+            return ((Number) result).longValue();
+        } catch (IllegalArgumentException e) {
+            if (!shouldFail)
+                throw e;
+            return -1;
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSimple.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSimple.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSimple.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,102 @@
+/*
+ * 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.openjpa.persistence.query;
+
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+
+import org.apache.openjpa.persistence.query.common.apps.Entity1;
+
+public class TestSimple extends BaseQueryTest {
+
+    private Query q = null;
+
+    public TestSimple(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        deleteAll(Entity1.class);
+    }
+
+    public void testSimple() throws java.io.IOException {
+        // test create
+        {
+            EntityManager em = currentEntityManager();
+            startTx(em);
+            em.persist(new Entity1(0, "testSimple", 12));
+            endTx(em);
+            endEm(em);
+        }
+
+        // test Query
+        {
+            EntityManager em = currentEntityManager();
+            startTx(em);
+            List l = em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple'").getResultList();
+            assertSize(1, l);
+            endTx(em);
+            endEm(em);
+        }
+
+        // test Update
+        {
+            EntityManager em = currentEntityManager();
+            startTx(em);
+            ((Entity1) em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple'").getSingleResult())
+                .setStringField("testSimple2");
+            endTx(em);
+            endEm(em);
+
+            em = currentEntityManager();
+            startTx(em);
+            q = em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple'");
+            assertSize(0, q);
+            q = em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple2'");
+            assertSize(1, q);
+            endTx(em);
+            endEm(em);
+        }
+
+        // test delete
+        {
+            EntityManager em = currentEntityManager();
+            startTx(em);
+            em.remove(em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple2'").getSingleResult());
+            endTx(em);
+            endEm(em);
+
+            em = currentEntityManager();
+            startTx(em);
+
+            q = em.createQuery("SELECT o FROM Entity1 o "
+                + "WHERE o.stringField = 'testSimple2'");
+            assertSize(0, q);
+            endTx(em);
+            endEm(em);
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+/**
+ * <p>Persistent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+
+import javax.persistence.Entity;
+
+@Entity
+public class CircularFKPC {
+
+    private String stringField;
+    private CircularFKPC2 fkField;
+
+    public String getStringField() {
+        return this.stringField;
+    }
+
+    public void setStringField(String stringField) {
+        this.stringField = stringField;
+    }
+
+    public CircularFKPC2 getFKField() {
+        return this.fkField;
+    }
+
+    public void setFKField(CircularFKPC2 fkField) {
+        this.fkField = fkField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CircularFKPC2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+/**
+ * <p>Persistent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+
+import javax.persistence.Entity;
+
+@Entity
+public class CircularFKPC2 {
+
+    private String stringField;
+    private CircularFKPC fkField;
+
+    public String getStringField() {
+        return this.stringField;
+    }
+
+    public void setStringField(String stringField) {
+        this.stringField = stringField;
+    }
+
+    public CircularFKPC getFKField() {
+        return this.fkField;
+    }
+
+    public void setFKField(CircularFKPC fkField) {
+        this.fkField = fkField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexA.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexA.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexA.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.LinkedList;
+import javax.persistence.Entity;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexA {
+
+    private String stringA;
+    private int intA;
+    @Temporal(TemporalType.DATE)
+    private Date dateA;
+    private Collection bs = new LinkedList();
+
+    public ComplexA() {
+
+    }
+
+    public ComplexA(String stringA, int intA, Date dateA, ComplexB[] bs) {
+        this.stringA = stringA;
+        this.intA = intA;
+        this.dateA = dateA;
+        if (bs != null)
+            this.bs.addAll(Arrays.asList(bs));
+    }
+
+    public void setStringA(String stringA) {
+        this.stringA = stringA;
+    }
+
+    public String getStringA() {
+        return this.stringA;
+    }
+
+    public void setIntA(int intA) {
+        this.intA = intA;
+    }
+
+    public int getIntA() {
+        return this.intA;
+    }
+
+    public void setDateA(Date dateA) {
+        this.dateA = dateA;
+    }
+
+    public Date getDateA() {
+        return this.dateA;
+    }
+
+    public void setBs(Collection bs) {
+        this.bs = bs;
+    }
+
+    public Collection getBs() {
+        return this.bs;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexB.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexB.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexB.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,97 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexB
+    extends ComplexA {
+
+    private String stringB;
+    private int intB;
+    @Temporal(TemporalType.DATE)
+    private Date dateB;
+    private Collection cs = new ArrayList();
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexA a;
+
+    public ComplexB() {
+
+    }
+
+    public ComplexB(String stringB, int intB, Date dateB, ComplexC[] cs,
+        ComplexA a) {
+        this.stringB = stringB;
+        this.intB = intB;
+        this.dateB = dateB;
+        if (cs != null)
+            this.cs.addAll(Arrays.asList(cs));
+        this.a = a;
+    }
+
+    public void setStringB(String stringB) {
+        this.stringB = stringB;
+    }
+
+    public String getStringB() {
+        return this.stringB;
+    }
+
+    public void setIntB(int intB) {
+        this.intB = intB;
+    }
+
+    public int getIntB() {
+        return this.intB;
+    }
+
+    public void setDateB(Date dateB) {
+        this.dateB = dateB;
+    }
+
+    public Date getDateB() {
+        return this.dateB;
+    }
+
+    public void setCs(Collection cs) {
+        this.cs = cs;
+    }
+
+    public Collection getCs() {
+        return this.cs;
+    }
+
+    public void setA(ComplexA a) {
+        this.a = a;
+    }
+
+    public ComplexA getA() {
+        return this.a;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,97 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexC
+    extends ComplexB {
+
+    private String stringC;
+    private int intC;
+    @Temporal(TemporalType.DATE)
+    private Date dateC;
+    private Set ds = new HashSet();
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexB b;
+
+    public ComplexC() {
+
+    }
+
+    public ComplexC(String stringC, int intC, Date dateC, ComplexD[] ds,
+        ComplexB b) {
+        this.stringC = stringC;
+        this.intC = intC;
+        this.dateC = dateC;
+        if (ds != null)
+            this.ds.addAll(Arrays.asList(ds));
+        this.b = b;
+    }
+
+    public void setStringC(String stringC) {
+        this.stringC = stringC;
+    }
+
+    public String getStringC() {
+        return this.stringC;
+    }
+
+    public void setIntC(int intC) {
+        this.intC = intC;
+    }
+
+    public int getIntC() {
+        return this.intC;
+    }
+
+    public void setDateC(Date dateC) {
+        this.dateC = dateC;
+    }
+
+    public Date getDateC() {
+        return this.dateC;
+    }
+
+    public void setDs(Set ds) {
+        this.ds = ds;
+    }
+
+    public Set getDs() {
+        return this.ds;
+    }
+
+    public void setB(ComplexB b) {
+        this.b = b;
+    }
+
+    public ComplexB getB() {
+        return this.b;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexD.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexD.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexD.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,96 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexD {
+
+    private String stringD;
+    private int intD;
+    @Temporal(TemporalType.DATE)
+    private Date dateD;
+    private Set es = new TreeSet();
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexC c;
+
+    public ComplexD() {
+
+    }
+
+    public ComplexD(String stringD, int intD, Date dateD, ComplexE[] es,
+        ComplexC c) {
+        this.stringD = stringD;
+        this.intD = intD;
+        this.dateD = dateD;
+        if (es != null)
+            this.es.addAll(Arrays.asList(es));
+        this.c = c;
+    }
+
+    public void setStringD(String stringD) {
+        this.stringD = stringD;
+    }
+
+    public String getStringD() {
+        return this.stringD;
+    }
+
+    public void setIntD(int intD) {
+        this.intD = intD;
+    }
+
+    public int getIntD() {
+        return this.intD;
+    }
+
+    public void setDateD(Date dateD) {
+        this.dateD = dateD;
+    }
+
+    public Date getDateD() {
+        return this.dateD;
+    }
+
+    public void setEs(Set es) {
+        this.es = es;
+    }
+
+    public Set getEs() {
+        return this.es;
+    }
+
+    public void setC(ComplexC c) {
+        this.c = c;
+    }
+
+    public ComplexC getC() {
+        return this.c;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexE.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexE.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexE.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,97 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.LinkedList;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexE
+    extends ComplexD {
+
+    private String stringE;
+    private int intE;
+    @Temporal(TemporalType.DATE)
+    private Date dateE;
+    private Collection fs = new LinkedList();
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexD d;
+
+    public ComplexE() {
+
+    }
+
+    public ComplexE(String stringE, int intE, Date dateE, ComplexF[] fs,
+        ComplexD d) {
+        this.stringE = stringE;
+        this.intE = intE;
+        this.dateE = dateE;
+        if (fs != null)
+            this.fs.addAll(Arrays.asList(fs));
+        this.d = d;
+    }
+
+    public void setStringE(String stringE) {
+        this.stringE = stringE;
+    }
+
+    public String getStringE() {
+        return this.stringE;
+    }
+
+    public void setIntE(int intE) {
+        this.intE = intE;
+    }
+
+    public int getIntE() {
+        return this.intE;
+    }
+
+    public void setDateE(Date dateE) {
+        this.dateE = dateE;
+    }
+
+    public Date getDateE() {
+        return this.dateE;
+    }
+
+    public void setFs(Collection fs) {
+        this.fs = fs;
+    }
+
+    public Collection getFs() {
+        return this.fs;
+    }
+
+    public void setD(ComplexD d) {
+        this.d = d;
+    }
+
+    public ComplexD getD() {
+        return this.d;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexF.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexF.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexF.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,97 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexF
+    extends ComplexE {
+
+    private String stringF;
+    private int intF;
+    @Temporal(TemporalType.DATE)
+    private Date dateF;
+    private Collection gs = new HashSet();
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexE e;
+
+    public ComplexF() {
+
+    }
+
+    public ComplexF(String stringF, int intF, Date dateF, ComplexG[] gs,
+        ComplexE e) {
+        this.stringF = stringF;
+        this.intF = intF;
+        this.dateF = dateF;
+        if (gs != null)
+            this.gs.addAll(Arrays.asList(gs));
+        this.e = e;
+    }
+
+    public void setStringF(String stringF) {
+        this.stringF = stringF;
+    }
+
+    public String getStringF() {
+        return this.stringF;
+    }
+
+    public void setIntF(int intF) {
+        this.intF = intF;
+    }
+
+    public int getIntF() {
+        return this.intF;
+    }
+
+    public void setDateF(Date dateF) {
+        this.dateF = dateF;
+    }
+
+    public Date getDateF() {
+        return this.dateF;
+    }
+
+    public void setGs(Collection gs) {
+        this.gs = gs;
+    }
+
+    public Collection getGs() {
+        return this.gs;
+    }
+
+    public void setE(ComplexE e) {
+        this.e = e;
+    }
+
+    public ComplexE getE() {
+        return this.e;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexG.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexG.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ComplexG.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Date;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class ComplexG
+    extends ComplexE {
+
+    private String stringG;
+    private int intG;
+    @Temporal(TemporalType.DATE)
+    private Date dateG;
+    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ComplexF f;
+
+    public ComplexG() {
+
+    }
+
+    public ComplexG(String stringG, int intG, Date dateG, ComplexF f) {
+        this.stringG = stringG;
+        this.intG = intG;
+        this.dateG = dateG;
+        this.f = f;
+    }
+
+    public void setStringG(String stringG) {
+        this.stringG = stringG;
+    }
+
+    public String getStringG() {
+        return this.stringG;
+    }
+
+    public void setIntG(int intG) {
+        this.intG = intG;
+    }
+
+    public int getIntG() {
+        return this.intG;
+    }
+
+    public void setDateG(Date dateG) {
+        this.dateG = dateG;
+    }
+
+    public Date getDateG() {
+        return this.dateG;
+    }
+
+    public void setF(ComplexF f) {
+        this.f = f;
+    }
+
+    public ComplexF getF() {
+        return this.f;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CompoundAppIdPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CompoundAppIdPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/CompoundAppIdPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+/**
+ * <p>Application identity type with a compound primary key.</p>
+ *
+ * @author Abe White
+ */
+
+@Entity
+@IdClass(CompoundAppIdPC.Idkey.class)
+public class CompoundAppIdPC {
+
+    @Id
+    private String pk1;
+
+    @Id
+    private int pk2;
+
+    private int intField;
+
+    public String getPk1() {
+        return this.pk1;
+    }
+
+    public void setPk1(String pk1) {
+        this.pk1 = pk1;
+    }
+
+    public int getPk2() {
+        return this.pk2;
+    }
+
+    public void setPk2(int pk2) {
+        this.pk2 = pk2;
+    }
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+
+    public static class Idkey implements Serializable {
+
+        public String pk1;
+        public int pk2;
+
+        public Idkey() {
+        }
+
+        public Idkey(String str) {
+            int index = str.indexOf("/");
+            if (index != -1) {
+                pk2 = Integer.parseInt(str.substring(0, index));
+                pk1 = str.substring(index + 1);
+            }
+        }
+
+        public String toString() {
+            return pk2 + "/" + pk1;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof Idkey))
+                return false;
+
+            Idkey id = (Idkey) other;
+            if (pk1 == null && id.pk1 != null)
+                return false;
+            if (pk1 != null && id.pk1 == null)
+                return false;
+            if (!(pk1 == id.pk1))
+                return false;
+            if (!(pk1.equals(id.pk1)))
+                return false;
+
+            return true;
+        }
+
+        @Override
+        public int hashCode() {
+            return (pk2 + pk1).hashCode();
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,104 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+@Entity
+@Table(name = "entity_1")
+@Inheritance(strategy = InheritanceType.JOINED)
+@SqlResultSetMapping(name = "NativeTestResult",
+    entities = @EntityResult(entityClass = Entity1.class))
+@NamedQuery(name = "setParam1",
+    query = "SELECT o FROM Entity1 o WHERE o.stringField = :fld")
+public class Entity1 implements Serializable {
+
+    private static final long serialVersionUID = 2882935803066041165L;
+
+    @Id
+    protected long pk;
+
+    @Basic
+    @Column(length = 35)
+    protected String stringField;
+
+    @Basic
+    protected int intField;
+
+    @OneToOne(cascade = { CascadeType.REMOVE, CascadeType.PERSIST })
+    protected Entity2 entity2Field;
+
+    @Version
+    protected int versionField;
+
+    public Entity1() {
+    }
+
+    public Entity1(long pk, String stringField, int intField) {
+        this.pk = pk;
+        this.stringField = stringField;
+        this.intField = intField;
+    }
+
+    public long getPk() {
+        return pk;
+    }
+
+    public void setStringField(String val) {
+        stringField = val;
+    }
+
+    public String getStringField() {
+        return stringField;
+    }
+
+    public void setIntField(int val) {
+        intField = val;
+    }
+
+    public int getIntField() {
+        return intField;
+    }
+
+    public void setEntity2Field(Entity2 val) {
+        entity2Field = val;
+    }
+
+    public Entity2 getEntity2Field() {
+        return entity2Field;
+    }
+
+    public String toString() {
+        return ("PK: " + pk + " StringField: " + stringField + " IntField: " +
+            intField);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/Entity2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,86 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+//@Entity(name="entity2ExplicitName")
+
+//@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+/**
+ * FIX-ME
+ * <p/>
+ * It should complain if i uncomment the above strategies...but it does
+ */
+@Entity
+public class Entity2 implements Serializable {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 4723739219953167343L;
+
+    @Id
+    protected long pk;
+
+    @Basic
+    @Column(length = 35)
+    protected String stringField;
+
+    @Basic
+    protected int intField;
+
+    public Entity2() {
+    }
+
+    public Entity2(long pk, String stringField, int intField) {
+        this.pk = pk;
+        this.stringField = stringField;
+        this.intField = intField;
+    }
+
+    public long getPk() {
+        return pk;
+    }
+
+    public void setStringField(String val) {
+        stringField = val;
+    }
+
+    public String getStringField() {
+        return stringField;
+    }
+
+    public void setIntField(int val) {
+        intField = val;
+    }
+
+    public int getIntField() {
+        return intField;
+    }
+
+    public String toString() {
+        return ("PK: " + pk + " StringField: " + stringField + " IntField: " +
+            intField);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,124 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+/**
+ * <p>Persitent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+@Table(name = "mrtest1")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+public class ModRuntimeTest1 implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Transient
+    public static final String someStaticField = "someField";
+
+    private Locale localeField;
+
+    @Id
+    private int intField;
+
+    @Column(length = 35)
+    private String stringField;
+
+    @Column(length = 35)
+    public String transString;
+
+    @OneToOne(fetch = FetchType.LAZY,
+        cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+    private ModRuntimeTest1 selfOneOne;
+
+    @Transient
+    private Set selfOneMany = new HashSet();
+
+    public ModRuntimeTest1() {
+    }
+
+    public ModRuntimeTest1(int key) {
+        this.intField = key;
+    }
+
+    public ModRuntimeTest1(String str, int i) {
+        stringField = str;
+        intField = i;
+    }
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+
+    public String getStringField() {
+        return this.stringField;
+    }
+
+    public void setStringField(String stringField) {
+        this.stringField = stringField;
+    }
+
+    public ModRuntimeTest1 getSelfOneOne() {
+        return this.selfOneOne;
+    }
+
+    public void setSelfOneOne(ModRuntimeTest1 selfOneOne) {
+        this.selfOneOne = selfOneOne;
+    }
+
+    public Set getSelfOneMany() {
+        return this.selfOneMany;
+    }
+
+    public void setSelfOneMany(Set selfOneMany) {
+        this.selfOneMany = selfOneMany;
+    }
+
+    public String toString() {
+        return "IntField: " + intField + ", StringField: " + stringField + " .";
+    }
+
+    public Locale getLocaleField() {
+        return localeField;
+    }
+
+    public void setLocaleField(Locale localeField) {
+        this.localeField = localeField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/ModRuntimeTest2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,56 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * <p>Persitent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+@DiscriminatorValue("mRT2")
+public class ModRuntimeTest2 extends ModRuntimeTest1 {
+
+    private static final long serialVersionUID = 1L;
+    private int intField2;
+
+    public ModRuntimeTest2(int key) {
+        super(key);
+    }
+
+    public ModRuntimeTest2(String str, int i) {
+        super(str, i);
+    }
+
+    public int getIntField2() {
+        return this.intField2;
+    }
+
+    public void setIntField2(int intField2) {
+        this.intField2 = intField2;
+    }
+
+    public String toString() {
+        return "IntField: " + intField2 + ", StringField: " +
+            super.getStringField() + " .";
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,149 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Date;
+import java.util.List;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+
+/**
+ * <p>Used in testing; should be enhanced.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+@NamedQueries({
+@NamedQuery(name = "named",
+    query = "SELECT o FROM QueryTest1 o"),
+@NamedQuery(name = "sql",
+    query = "select * from foo"),
+@NamedQuery(name = "systemsql",
+    query = "select * from foo"),
+@NamedQuery(name = "systemjdoql",
+    query = "select o FROM QueryTest1 where o.numb == 4")
+    })
+public class QueryTest1 {
+
+    /*
+      * Changed Variable names : Afam Okeke
+      * Reason: The old var names are reserved my some DB's namely MYSQL.
+      */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    public int id;
+
+    public static final long FIVE = 5L;
+
+    private long numb = 0L;
+    private String strong = null;
+
+    @Column(length = -1)
+    private String cField = null;
+    private boolean boolt = false;
+    private float decar = 1.0f;
+    private char chart = ' ';
+    private Date datum = null;
+
+    @ManyToMany(mappedBy = "manyToMany3")
+    private List<QueryTest4> manyToMany = null;
+
+    public QueryTest1() {
+        decar = 1.0f;
+    }
+
+    public QueryTest1(int id) {
+        decar = 1.0f;
+        this.id = id;
+    }
+
+    public long getNum() {
+        return numb;
+    }
+
+    public void setNum(long val) {
+        numb = val;
+    }
+
+    public String getString() {
+        return strong;
+    }
+
+    public void setString(String val) {
+        strong = val;
+    }
+
+    public String getClob() {
+        return cField;
+    }
+
+    public void setClob(String val) {
+        cField = val;
+    }
+
+    public boolean getBool() {
+        return boolt;
+    }
+
+    public void setBool(boolean val) {
+        boolt = val;
+    }
+
+    public float getDecimal() {
+        return decar;
+    }
+
+    public void setDecimal(float val) {
+        decar = val;
+    }
+
+    public char getCharacter() {
+        return chart;
+    }
+
+    public void setCharacter(char val) {
+        chart = val;
+    }
+
+    public void setDate(Date val) {
+        datum = val;
+    }
+
+    public Date getDate() {
+        return datum;
+    }
+
+    public List<QueryTest4> getManyToMany() {
+        return manyToMany;
+    }
+
+    public void setManyToMany(List<QueryTest4> val) {
+        manyToMany = val;
+    }
+
+    public int getId() {
+        return this.id;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,106 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import javax.persistence.CascadeType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+import org.apache.openjpa.persistence.PersistentCollection;
+import org.apache.openjpa.persistence.PersistentMap;
+import org.apache.openjpa.persistence.jdbc.KeyColumn;
+
+/**
+ * <p>Used in testing; should be enhanced.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+@DiscriminatorValue("query2")
+public class QueryTest2 extends QueryTest1 {
+
+    @OneToOne(cascade = { CascadeType.ALL })
+    private QueryTest2 oneToOne = null;
+
+    @PersistentCollection
+    private List<String> stringCollection = null;
+
+    @OneToMany(cascade = { CascadeType.ALL })
+    private List<QueryTest2> oneToMany = null;
+
+    @PersistentMap
+    @KeyColumn(name = "SMAP")
+    private Map<String, String> stringMap = null;
+
+    @OneToMany(cascade = { CascadeType.ALL })
+    @KeyColumn(name = "QT2")
+    private Map<String, QueryTest2> stringToManyMap = null;
+
+    public QueryTest2() {
+    }
+
+    public QueryTest2(int id) {
+        super(id);
+    }
+
+    public QueryTest2 getOneToOne() {
+        return oneToOne;
+    }
+
+    public void setOneToOne(QueryTest2 val) {
+        oneToOne = val;
+    }
+
+    public Collection getStringCollection() {
+        return stringCollection;
+    }
+
+    public void setStringCollection(List<String> val) {
+        stringCollection = val;
+    }
+
+    public Collection getOneToMany() {
+        return oneToMany;
+    }
+
+    public void setOneToMany(List<QueryTest2> val) {
+        oneToMany = val;
+    }
+
+    public Map getStringMap() {
+        return stringMap;
+    }
+
+    public void setStringMap(Map val) {
+        stringMap = val;
+    }
+
+    public Map getStringToManyMap() {
+        return stringToManyMap;
+    }
+
+    public void setStringToManyMap(Map val) {
+        stringToManyMap = val;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/op...
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/common/apps/QueryTest3.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.openjpa.persistence.query.common.apps;
+
+import javax.persistence.Entity;
+
+/**
+ * <p>Used in testing; should be enhanced.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+public class QueryTest3 extends QueryTest2 {
+
+    private int num2 = 0;
+
+    public QueryTest3() {
+    }
+
+    public QueryTest3(int id) {
+        super(id);
+    }
+
+    public void setNum2(int val) {
+        num2 = val;
+    }
+}
Home | About | Privacy