openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1806889 - /openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
Date Fri, 01 Sep 2017 06:40:16 GMT
Author: ilgrosso
Date: Fri Sep  1 06:40:16 2017
New Revision: 1806889

URL: http://svn.apache.org/viewvc?rev=1806889&view=rev
Log:
[OPENJPA-2598] Applying provided patch

Modified:
    openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java

Modified: openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java?rev=1806889&r1=1806888&r2=1806889&view=diff
==============================================================================
--- openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
(original)
+++ openjpa/branches/2.4.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
Fri Sep  1 06:40:16 2017
@@ -72,7 +72,7 @@ public class SQLServerDictionary extends
         String driverName = meta.getDriverName();
         String url = meta.getURL();
         if (driverVendor == null) {
-            // serverMajorVersion of 8==2000, 9==2005, 10==2008
+            // serverMajorVersion of 8==2000, 9==2005, 10==2008,  11==2012
             if (meta.getDatabaseMajorVersion() >= 9)
                 setSupportsXMLColumn(true);
             if (meta.getDatabaseMajorVersion() >= 10) {
@@ -83,6 +83,12 @@ public class SQLServerDictionary extends
                 timestampTypeName = "DATETIME2";
                 datePrecision = MICRO / 10;
             }
+            if (meta.getDatabaseMajorVersion() >= 11) {
+                //SQLServer 2012 supports range select
+                rangePosition = RANGE_POST_SELECT;      
+                supportsSelectStartIndex = true;
+                supportsSelectEndIndex = true;
+            }
             if (driverName != null) {
                 if (driverName.startsWith("Microsoft SQL Server")) {
                     // v1.1, 1.2, 2.0 or 3.0 driver
@@ -342,4 +348,19 @@ public class SQLServerDictionary extends
         }
         buf.append(")");
     }
+
+    @Override
+    protected void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)
{
+        //SQL Server 2012 supports range select
+        if (this.getMajorVersion() >= 11) {
+            //we need an order by clause....
+            if (!buf.getSQL().contains(" ORDER BY ")) {
+                buf.append(" ORDER BY 1 ");
+            }
+            buf.append(" OFFSET ").append(Long.toString(start)).append(" ROWS ").
+                    append(" FETCH NEXT ").append(Long.toString(end - start)).append(" ROWS
ONLY ");
+        } else {
+            super.appendSelectRange(buf, start, end, subselect);
+        }
+    }
 }



Mime
View raw message