OPENJPA-2713 add java8 time api for SQLServer

This commit is contained in:
Mark Struberg 2019-02-07 12:52:40 +01:00
parent 0e4ec5b392
commit c1ae373a0f
2 changed files with 53 additions and 1 deletions

View File

@ -73,6 +73,7 @@ public abstract class AbstractSQLServerDictionary
dateTypeName = "DATETIME";
timeTypeName = "DATETIME";
timestampTypeName = "DATETIME";
timestampWithZoneTypeName = "DATETIMEOFFSET";
floatTypeName = "FLOAT(16)";
doubleTypeName = "FLOAT(32)";
integerTypeName = "INT";

View File

@ -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(")");
}