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
This commit is contained in:
Albert Lee 2011-03-29 16:38:59 +00:00
parent 59c9ec99af
commit f10e349f7c
1 changed files with 11 additions and 10 deletions

View File

@ -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;