You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by al...@apache.org on 2011/03/29 18:38:59 UTC

svn commit: r1086639 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java

Author: allee8285
Date: Tue Mar 29 16:38:59 2011
New Revision: 1086639

URL: http://svn.apache.org/viewvc?rev=1086639&view=rev
Log:
OPENJPA-1968 Set DATETIME2 based on db version and also set the correct date_precision for DATETIME2 type.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java?rev=1086639&r1=1086638&r2=1086639&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java Tue Mar 29 16:38:59 2011
@@ -71,13 +71,21 @@ public class SQLServerDictionary extends
         String driverName = meta.getDriverName();
         String url = meta.getURL();
         if (driverVendor == null) {
+            // serverMajorVersion of 8==2000, 9==2005, 10==2008
+            if (meta.getDatabaseMajorVersion() >= 9)
+                setSupportsXMLColumn(true);
+            if (meta.getDatabaseMajorVersion() >= 10) {
+                // MSSQL 2008 supports new date, time and datetime2 types
+                // Use DATETIME2 which has 100ns vs. 3.333msec precision
+                dateTypeName = "DATETIME2";
+                timeTypeName = "DATETIME2";
+                timestampTypeName = "DATETIME2";
+                datePrecision = MICRO / 10;
+            }
             if (driverName != null) {
                 if (driverName.startsWith("Microsoft SQL Server")) {
                     // v1.1, 1.2, 2.0 or 3.0 driver
                     driverVendor = VENDOR_MICROSOFT;
-                    // serverMajorVersion of 8==2000, 9==2005, 10==2008
-                    if (meta.getDatabaseMajorVersion() >= 9)
-                        setSupportsXMLColumn(true);
                     if (meta.getDriverMajorVersion() >= 2) {
                         // see http://blogs.msdn.com/jdbcteam/archive/2007/05/\
                         // 02/what-is-adaptive-response-buffering-and-why-\
@@ -87,13 +95,6 @@ public class SQLServerDictionary extends
                         // and disableStatementPooling=true
                         requiresWarnings = false;
                     }
-                    if (meta.getDatabaseMajorVersion() >= 10) {
-                        // MSSQL 2008 supports new date, time and datetime2 types
-                        // Use DATETIME2 which has 100ns vs. 3.333msec precision
-                        dateTypeName = "DATETIME2";
-                        timeTypeName = "DATETIME2";
-                        timestampTypeName = "DATETIME2";
-                    }
                 } else {
                     if ("NetDirect JSQLConnect".equals(driverName))
                         driverVendor = VENDOR_NETDIRECT;