From f10e349f7c356291d32173541c3936e0253243b8 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 29 Mar 2011 16:38:59 +0000 Subject: [PATCH] OPENJPA-1968 Set DATETIME2 based on db version and also set the correct date_precision for DATETIME2 type. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1086639 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/sql/SQLServerDictionary.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java index dbe121c82..5a4e95f32 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java @@ -71,13 +71,21 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { 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 AbstractSQLServerDictionary { // 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;