Author: allee8285
Date: Tue Jul  9 13:25:21 2013
New Revision: 1501256

URL: http://svn.apache.org/r1501256
Log:
OPENJPA-2356 Database specific adjustments for previous patch. Contributed by 
Di Lau.

Modified:
    
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
    
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1501256&r1=1501255&r2=1501256&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
 Tue Jul  9 13:25:21 2013
@@ -5665,5 +5665,8 @@ public class DBDictionary
         return s == null ? "" : s;
     }
 
+       public int applyRange(Select select, int count) {
+               return count;
+       }
 
 }

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java?rev=1501256&r1=1501255&r2=1501256&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
 Tue Jul  9 13:25:21 2013
@@ -199,4 +199,28 @@ public class DerbyDictionary
         return super.isFatalException(subtype, ex);
     }
     
+       /**
+        * Applies range calculation on the actual number of rows selected by a
+        * {@code COUNT(*)} query. A range query may use either only the limit 
or
+        * both offset and limit based on database dictionary support and
+        * accordingly the number of rows in the result set needs to be 
modified.
+        * 
+        * @param select
+        * @param count
+        * @return
+        */
+
+       public int applyRange(Select select, int count) {
+               long start = select.getStartIndex();
+               long end = select.getEndIndex();
+               if (supportsSelectStartIndex) {
+                       if (start > 0)
+                               count -= start;
+                       if (end != Long.MAX_VALUE) {
+                               long size = end - start;
+                               count = (int) Math.min(count, size);
+                       }
+               }
+               return count;
+       }
 }

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=1501256&r1=1501255&r2=1501256&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
 Tue Jul  9 13:25:21 2013
@@ -366,7 +366,7 @@ public class SelectImpl
             rs = executeQuery(conn, stmnt, sql, false, store);
             int count =  getCount(rs);
              
-            return applyRange(count);
+            return _dict.applyRange(this, count);
         } finally {
             if (rs != null)
                 try { rs.close(); } catch (SQLException se) {}
@@ -376,27 +376,6 @@ public class SelectImpl
                 try { conn.close(); } catch (SQLException se) {}
         }
     }
-    
-    /**
-     * Applies range calculation on the actual number of rows selected
-     * by a {@code COUNT(*)} query. A range query may use either only
-     * the limit or both offset and limit based on database dictionary support
-     * and accordingly the number of rows in the result set needs to be 
-     * modified.
-     * @param count
-     * @return
-     */
-    int applyRange(int count) {
-       DBDictionary dict = getDictionary();
-       if (dict.supportsSelectStartIndex) {
-            if (getStartIndex() > 0) count -= getStartIndex();
-            if (getEndIndex() != Long.MAX_VALUE) {
-               long size = getEndIndex() - getStartIndex();
-               count = (int)Math.min(count,size);
-            }
-       }
-       return count;          
-    }
 
     public Result execute(JDBCStore store, JDBCFetchConfiguration fetch)
         throws SQLException {


Reply via email to