fix formatting and readability
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 c5e2eb3..8d397b6 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
@@ -60,6 +60,15 @@
*/
public boolean uniqueIdentifierAsVarbinary = true;
+ /**
+ * Whether to send Time values as DateTime or as Time.
+ * This affects how the Database actually looks like.
+ * sendTimeAsDatetime is supported as of SQLServer2008 and
+ * is only to be used with TIME columns.
+ * Previous to that a DATETIME column had to be used with a fixed 1970-01-01 date.
+ */
+ public Boolean sendTimeAsDatetime = null;
+
public SQLServerDictionary() {
platform = "Microsoft SQL Server";
// SQLServer locks on a table-by-table basis
@@ -69,10 +78,8 @@
requiresAliasForSubselect = true;
stringLengthFunction = "LEN({0})";
- timeTypeName = "TIME";
timeWithZoneTypeName = "TIME";
timestampWithZoneTypeName = "DATETIMEOFFSET";
-
}
@Override
@@ -84,13 +91,17 @@
String url = meta.getURL();
if (driverVendor == null) {
// serverMajorVersion of 8==2000, 9==2005, 10==2008, 11==2012
- if (meta.getDatabaseMajorVersion() >= 9)
+ if (meta.getDatabaseMajorVersion() >= 9) {
setSupportsXMLColumn(true);
+ if (sendTimeAsDatetime == null) {
+ sendTimeAsDatetime = Boolean.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";
+ dateTypeName = "DATE";
+ timeTypeName = "TIME";
timestampTypeName = "DATETIME2";
datePrecision = MICRO / 10;
}
@@ -402,7 +413,7 @@
if (start != null) {
buf.append(", ");
start.appendTo(buf);
-p }
+ }
buf.append(")");
}
diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
index 778ca72..bd36acd 100644
--- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
+++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
@@ -246,13 +246,14 @@
@Override
public CriteriaQuery<T> groupBy(Expression<?>... grouping) {
- if (grouping == null) {
- _groups = null;
- return this;
- }
+ if (grouping == null) {
+ _groups = null;
+ return this;
+ }
_groups = new ArrayList<>();
- for (Expression<?> e : grouping)
- _groups.add(e);
+ for (Expression<?> e : grouping) {
+ _groups.add(e);
+ }
return this;
}
@@ -284,8 +285,9 @@
return this;
}
_having = new PredicateImpl.And();
- for (Predicate p : restrictions)
- _having.add(p);
+ for (Predicate p : restrictions) {
+ _having.add(p);
+ }
return this;
}
@@ -718,8 +720,9 @@
}
private void renderList(StringBuilder buffer, String clause, Collection<?> coll) {
- if (coll == null || coll.isEmpty())
+ if (coll == null || coll.isEmpty()) {
return;
+ }
buffer.append(clause);
for (Iterator<?> i = coll.iterator(); i.hasNext(); ) {
@@ -729,7 +732,10 @@
}
private void renderJoins(StringBuilder buffer, Collection<Join<?,?>> joins) {
- if (joins == null) return;
+ if (joins == null) {
+ return;
+ }
+
for (Join j : joins) {
buffer.append(((CriteriaExpression)j).asVariable(this)).append(" ");
renderJoins(buffer, j.getJoins());
@@ -738,7 +744,9 @@
}
private void renderRoots(StringBuilder buffer, Collection<Root<?>> roots) {
- if (roots == null) return;
+ if (roots == null) {
+ return;
+ }
int i = 0;
for (Root r : roots) {
buffer.append(((ExpressionImpl<?>)r).asVariable(this));
@@ -748,7 +756,9 @@
}
}
private void renderFetches(StringBuilder buffer, Set<Fetch> fetches) {
- if (fetches == null) return;
+ if (fetches == null) {
+ return;
+ }
for (Fetch j : fetches) {
buffer.append(((ExpressionImpl<?>)j).asValue(this)).append(" ");
}
diff --git a/pom.xml b/pom.xml
index 16c8d61..f4893c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,7 +80,7 @@
<mysql.connector.version>5.1.47</mysql.connector.version>
<mariadb.connector.version>2.2.0</mariadb.connector.version>
<postgresql.connector.version>42.2.5</postgresql.connector.version>
- <mssql.connector.version>7.2.0.jre8</mssql.connector.version>
+ <mssql.connector.version>7.2.1</mssql.connector.version>
<!-- other common versions -->
<slf4j.version>1.7.23</slf4j.version>