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 583a28cae..b4995d67a 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 @@ public abstract class AbstractSQLServerDictionary 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 ab7e47cfa..c5e2eb3cc 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.Blob; 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 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { supportsNullTableForGetColumns = false; requiresAliasForSubselect = true; stringLengthFunction = "LEN({0})"; + + timeTypeName = "TIME"; + timeWithZoneTypeName = "TIME"; + timestampWithZoneTypeName = "DATETIMEOFFSET"; + } @Override @@ -341,6 +351,47 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { 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 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { if (start != null) { buf.append(", "); start.appendTo(buf); - } +p } buf.append(")"); }