OPENJPA-2713 add java8 time api for SQLServer
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
index 583a28c..b4995d6 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
@@ -73,6 +73,7 @@
dateTypeName = "DATETIME";
timeTypeName = "DATETIME";
timestampTypeName = "DATETIME";
+ timestampWithZoneTypeName = "DATETIMEOFFSET";
floatTypeName = "FLOAT(16)";
doubleTypeName = "FLOAT(32)";
integerTypeName = "INT";
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 ab7e47c..c5e2eb3 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
@@ -22,9 +22,14 @@
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
import java.util.Locale;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
@@ -63,6 +68,11 @@
supportsNullTableForGetColumns = false;
requiresAliasForSubselect = true;
stringLengthFunction = "LEN({0})";
+
+ timeTypeName = "TIME";
+ timeWithZoneTypeName = "TIME";
+ timestampWithZoneTypeName = "DATETIMEOFFSET";
+
}
@Override
@@ -341,6 +351,47 @@
return clob.getCharacterStream();
}
+
+ @Override
+ public LocalDate getLocalDate(ResultSet rs, int column) throws SQLException {
+ return rs.getObject(column, LocalDate.class);
+ }
+
+ @Override
+ public void setLocalTime(PreparedStatement stmnt, int idx, LocalTime val, Column col) throws SQLException {
+ stmnt.setObject(idx, val);
+ }
+
+ @Override
+ public LocalTime getLocalTime(ResultSet rs, int column) throws SQLException {
+ return rs.getObject(column, LocalTime.class);
+ }
+
+ @Override
+ public void setLocalDateTime(PreparedStatement stmnt, int idx, LocalDateTime val, Column col) throws SQLException {
+ stmnt.setObject(idx, val);
+ }
+
+ @Override
+ public LocalDateTime getLocalDateTime(ResultSet rs, int column) throws SQLException {
+ return rs.getObject(column, LocalDateTime.class);
+ }
+
+ @Override
+ public void setOffsetDateTime(PreparedStatement stmnt, int idx, OffsetDateTime val, Column col) throws SQLException {
+ stmnt.setObject(idx, val);
+ }
+
+ /**
+ * h2 does intentionally not support {@code getTimestamp()} for 'TIME WITH TIME ZONE' columns.
+ * See h2 ticket #413.
+ */
+ @Override
+ public OffsetDateTime getOffsetDateTime(ResultSet rs, int column) throws SQLException {
+ return rs.getObject(column, OffsetDateTime.class);
+ }
+
+
@Override
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
FilterValue start) {
@@ -351,7 +402,7 @@
if (start != null) {
buf.append(", ");
start.appendTo(buf);
- }
+p }
buf.append(")");
}