This is an automated email from the ASF dual-hosted git repository. struberg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openjpa.git
commit 1690076b37e70fb45d302b1af7a6c78256183a3b Author: Mark Struberg <[email protected]> AuthorDate: Thu Feb 14 15:25:50 2019 +0100 fix formatting and readability --- .../openjpa/jdbc/sql/SQLServerDictionary.java | 23 +++++++++++---- .../persistence/criteria/CriteriaQueryImpl.java | 34 ++++++++++++++-------- pom.xml | 2 +- 3 files changed, 40 insertions(+), 19 deletions(-) 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 class SQLServerDictionary extends AbstractSQLServerDictionary { */ 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 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { requiresAliasForSubselect = true; stringLengthFunction = "LEN({0})"; - timeTypeName = "TIME"; timeWithZoneTypeName = "TIME"; timestampWithZoneTypeName = "DATETIMEOFFSET"; - } @Override @@ -84,13 +91,17 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { 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 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary { 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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { @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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { 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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { } 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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { } 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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { } 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 @@ class CriteriaQueryImpl<T> implements OpenJPACriteriaQuery<T>, AliasContext { } } 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>
