openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r799057 - in /openjpa/branches/1.3.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/ openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/pe...
Date Wed, 29 Jul 2009 20:25:14 GMT
Author: dwoods
Date: Wed Jul 29 20:25:14 2009
New Revision: 799057

URL: http://svn.apache.org/viewvc?rev=799057&view=rev
Log:
OPENJPA-1002: fixed select range for Oracle drivers. Patch submitted by Amy Yang and Ravi
Palacherla backported from trunk.

Added:
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java
  (with props)
Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/common/apps/META-INF/persistence.xml

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=799057&r1=799056&r2=799057&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Jul 29 20:25:14 2009
@@ -1851,7 +1851,7 @@
         from.append("(");
         from.append(toSelect(subSelect, null, subFrom, where,
             sel.getGrouping(), sel.getHaving(), null, sel.isDistinct(),
-            false, sel.getStartIndex(), sel.getEndIndex(), true));
+            false, sel.getStartIndex(), sel.getEndIndex(), true, sel));
         from.append(")");
         if (requiresAliasForSubselect)
             from.append(" ").append(Select.FROM_SELECT_ALIAS);
@@ -2342,11 +2342,12 @@
     /**
      * Combine the given components into a SELECT statement.
      */
-    public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
+    protected SQLBuffer toSelect(SQLBuffer selects,
+        JDBCFetchConfiguration fetch,
         SQLBuffer from, SQLBuffer where, SQLBuffer group,
         SQLBuffer having, SQLBuffer order,
         boolean distinct, boolean forUpdate, long start, long end,
-        boolean subselect) {
+        boolean subselect, Select sel) {
         return toOperation(getSelectOperation(fetch), selects, from, where,
             group, having, order, distinct, start, end,
             getForUpdateClause(fetch, forUpdate, null), subselect);
@@ -2365,7 +2366,8 @@
     /**
      * Combine the given components into a SELECT statement.
      */
-    public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
+    protected SQLBuffer toSelect(SQLBuffer selects, 
+        JDBCFetchConfiguration fetch,
         SQLBuffer from, SQLBuffer where, SQLBuffer group,
         SQLBuffer having, SQLBuffer order,
         boolean distinct, boolean forUpdate, long start, long end,

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=799057&r1=799056&r2=799057&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
Wed Jul 29 20:25:14 2009
@@ -380,7 +380,16 @@
         return buf;
     }
 
-    public SQLBuffer toSelect(SQLBuffer select, JDBCFetchConfiguration fetch,
+    protected SQLBuffer toSelect(SQLBuffer select, JDBCFetchConfiguration fetch,
+        SQLBuffer tables, SQLBuffer where, SQLBuffer group,
+        SQLBuffer having, SQLBuffer order,
+        boolean distinct, boolean forUpdate, long start, long end,
+        boolean subselect, Select sel) {
+    	return toSelect(select, fetch, tables, where, group, having, order,
+            distinct, forUpdate, start, end, sel);
+    }
+
+    protected SQLBuffer toSelect(SQLBuffer select, JDBCFetchConfiguration fetch,
         SQLBuffer tables, SQLBuffer where, SQLBuffer group,
         SQLBuffer having, SQLBuffer order,
         boolean distinct, boolean forUpdate, long start, long end,

Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java?rev=799057&view=auto
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java
(added)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java
Wed Jul 29 20:25:14 2009
@@ -0,0 +1,92 @@
+/*
+ * 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.jdbc.meta;
+
+import java.util.*;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.kernel.jpql.JPQLParser;
+import org.apache.openjpa.persistence.FetchPlan;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.jdbc.common.apps.EagerOuterJoinPC;
+
+
+public class TestRangeQuery extends 
+        org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest {
+
+    /** Creates a new instance of TestRangeQuery */
+    public TestRangeQuery(String name) {
+        super(name);
+    }
+
+    public boolean skipTest() {
+        DBDictionary dict = ((JDBCConfiguration) getConfiguration()).
+                getDBDictionaryInstance();
+        return !dict.supportsSubselect;
+    }
+
+    public void setUp() {
+
+       deleteAll(HelperPC.class);
+       deleteAll(EagerOuterJoinPC2.class);
+       deleteAll(EagerOuterJoinPC.class);
+    }
+
+    public void testQueryRange() {
+        insertManyStringList();
+
+        OpenJPAEntityManager em =(OpenJPAEntityManager)currentEntityManager();
+        FetchPlan fetch = (FetchPlan) em.getFetchPlan();
+        fetch.addField(EagerOuterJoinPC.class, "stringList");
+        fetch.setFetchBatchSize(3);
+        OpenJPAQuery q = em.createQuery(JPQLParser.LANG_JPQL,
+                "select x from EagerOuterJoinPC x order by x.name asc");
+        q.setFirstResult(5).setMaxResults(15);
+
+        List results = (List) q.getResultList();
+        assertEquals(5, results.size());
+
+        for (int i = 0; i < results.size(); i++) {
+            EagerOuterJoinPC pc = (EagerOuterJoinPC) results.get(i);
+            assertEquals(String.valueOf(i + 5), pc.getName());
+        }
+        q.closeAll();
+        em.close();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void insertManyStringList() {
+        OpenJPAEntityManager em =(OpenJPAEntityManager)currentEntityManager();
+        startTx(em);;
+        for (int i = 0; i < 10; i++) {
+            EagerOuterJoinPC pc = new EagerOuterJoinPC();
+            pc.setName(String.valueOf(i));
+            pc.getStringList().add(i + ".1");
+            pc.getStringList().add(i + ".2");
+            em.persist(pc);
+        }
+        endTx(em);;
+        em.close();
+    }
+}

Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestRangeQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/common/apps/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/common/apps/META-INF/persistence.xml?rev=799057&r1=799056&r2=799057&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/common/apps/META-INF/persistence.xml
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/common/apps/META-INF/persistence.xml
Wed Jul 29 20:25:14 2009
@@ -39,5 +39,6 @@
 		<class>org.apache.openjpa.persistence.jdbc.common.apps.HelperPC4</class>
 		<class>org.apache.openjpa.persistence.jdbc.common.apps.InvertA</class>
         <class>org.apache.openjpa.persistence.jdbc.common.apps.InvertB</class>
+        <class>org.apache.openjpa.persistence.jdbc.common.apps.EagerOuterJoinPC</class>
 	</persistence-unit>
 </persistence>



Mime
View raw message