You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2019/01/29 13:53:11 UTC

[openjpa] branch master updated (5079209 -> be62c5a)

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


    from 5079209  Merge branch 'OPENJPA-2713'
     new 362474e  OPENJPA-2713 add java8 time support for MySQL and MariaDB
     new 9f0631b  switch back to old mariadb connectorj due to a bug
     new fffc74f  OPENJPA-2713 improve MariaDB Dictionary
     new e908a9c  formatting only
     new be62c5a  OPENJPA-2713 add LocalDate support for Oracle DB

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jdbc/kernel/exps/JDBCExpressionFactory.java    |  6 ++---
 .../apache/openjpa/jdbc/sql/MariaDBDictionary.java | 27 ++++++++++++++++---
 .../apache/openjpa/jdbc/sql/MySQLDictionary.java   | 20 +++++++++++----
 .../apache/openjpa/jdbc/sql/OracleDictionary.java  | 30 +++++++++++++++++++---
 .../criteria/TestTypeSafeCondExpression.java       |  5 ++--
 openjpa-project/BUILDING.txt                       | 14 ++++++++--
 pom.xml                                            |  2 +-
 7 files changed, 81 insertions(+), 23 deletions(-)


[openjpa] 03/05: OPENJPA-2713 improve MariaDB Dictionary

Posted by st...@apache.org.
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 fffc74f0a7f3e387c2cc9826ceabf6a11918468b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Mon Jan 28 13:00:05 2019 +0100

    OPENJPA-2713 improve MariaDB Dictionary
    
    Seems like MariaDB does still have quite a few problems in their JDBC driver.
    I at least tried to iron out new functionality.
---
 .../openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java   |  6 ++----
 .../org/apache/openjpa/jdbc/sql/MariaDBDictionary.java    | 15 ++++++++++++---
 openjpa-project/BUILDING.txt                              | 14 ++++++++++++--
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
index 04f3a19..ab00787 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
@@ -301,10 +301,8 @@ public class JDBCExpressionFactory
         String single, String multi, String esc) {
         if (!(v2 instanceof Const))
             throw new UserException(_loc.get("const-only", "matches"));
-        if (esc == null && _type.getMappingRepository().
-                getDBDictionary().requiresSearchStringEscapeForLike == true) {
-            esc = _type.getMappingRepository().
-                getDBDictionary().searchStringEscape;
+        if (esc == null && _type.getMappingRepository().getDBDictionary().requiresSearchStringEscapeForLike) {
+            esc = _type.getMappingRepository().getDBDictionary().searchStringEscape;
         }
         return new MatchesExpression((Val) v1, (Const) v2, single, multi, esc);
     }
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
index 106bc5b..4443a56 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
@@ -74,7 +74,7 @@ public class MariaDBDictionary extends DBDictionary {
      * combined <code>DELETE FROM foo, bar, baz</code> syntax.
      * Defaults to false, since this may fail in the presence of InnoDB tables
      * with foreign keys.
-     * @see http://dev.mysql.com/doc/refman/5.0/en/delete.html
+     * @link http://dev.mysql.com/doc/refman/5.0/en/delete.html
      */
     public boolean optimizeMultiTableDeletes = false;
 
@@ -98,6 +98,8 @@ public class MariaDBDictionary extends DBDictionary {
         supportsSelectStartIndex = true;
         supportsSelectEndIndex = true;
 
+        datePrecision = MICRO;
+
         concatenateFunction = "CONCAT({0},{1})";
 
         maxTableNameLength = 64;
@@ -153,11 +155,11 @@ public class MariaDBDictionary extends DBDictionary {
         }));
 
         requiresSearchStringEscapeForLike = true;
+
         // MariaDB requires double-escape for strings
         searchStringEscape = "\\\\";
 
-        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED",
-            "ZEROFILL" }));
+        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED", "ZEROFILL" }));
 
         setLeadingDelimiter(DELIMITER_BACK_TICK);
         setTrailingDelimiter(DELIMITER_BACK_TICK);
@@ -186,6 +188,13 @@ public class MariaDBDictionary extends DBDictionary {
         }
 
         supportsXMLColumn = true;
+
+        if (maj > 10 || (maj == 10 && min > 1)) {
+            // MariaDB supports fraction of a second
+            timestampTypeName = "DATETIME{0}";
+            fixedSizeTypeNameSet.remove(timestampTypeName);
+            fractionalTypeNameSet.add(timestampTypeName);
+        }
     }
 
     @Override
diff --git a/openjpa-project/BUILDING.txt b/openjpa-project/BUILDING.txt
index c002b6a..351d380 100644
--- a/openjpa-project/BUILDING.txt
+++ b/openjpa-project/BUILDING.txt
@@ -191,7 +191,7 @@ The generated PDF is available under ./target/docbook/manual.pdf
 
 Running unit tests in the Debugger
 ==================================
-TODO: finish!
+
 By default all tests run against a derby database.
 To run the tests in the debugger simply add the following JVM properties
 
@@ -203,4 +203,14 @@ For running against a MySQL Docker installation:
 
 Running against a PostgreSQL Docker installation:
 
- -ea -Dopenjpa.ConnectionDriverName=org.postgresql.Driver -Dopenjpa.ConnectionURL=jdbc:postgresql:5432//localhost/openjpatst -Dopenjpa.ConnectionUserName=postgres -Dopenjpa.ConnectionPassword=postgres
\ No newline at end of file
+ -ea -Dopenjpa.ConnectionDriverName=org.postgresql.Driver -Dopenjpa.ConnectionURL=jdbc:postgresql:5432//localhost/openjpatst -Dopenjpa.ConnectionUserName=postgres -Dopenjpa.ConnectionPassword=postgres
+
+For running against a MariaDB Docker installation:
+
+ -ea -Dopenjpa.ConnectionDriverName=org.mariadb.jdbc.Driver -Dopenjpa.ConnectionURL=jdbc:mariadb://localhost:3306/openjpatst -Dopenjpa.ConnectionUserName=root -Dopenjpa.ConnectionPassword=openjpatst
+
+TODO: finish!
+
+For starting tests in `openjpa-persistence-jdbc` inside a compiler you can also trigger all the enhancement manually via:
+
+ $> mvn process-test-classes


[openjpa] 02/05: switch back to old mariadb connectorj due to a bug

Posted by st...@apache.org.
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 9f0631bbf42aa01542a7d46c3bb610d6c0d3aa3c
Author: Mark Struberg <st...@apache.org>
AuthorDate: Sat Jan 26 21:55:30 2019 +0100

    switch back to old mariadb connectorj due to a bug
    
    MariaDB connectorj-2.3.0 has a bug with ESCAPE handling.
    This leads to many tests blow up with Exceptions.
    The respective bug is https://jira.mariadb.org/browse/CONJ-664
    2.3.1 should be safe again, but is not yet out.
    Thus switching back to 2.2.0.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 2de3e79..7a44eba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
         <derby.version>10.14.2.0</derby.version>
         <hsqldb.version>2.4.1</hsqldb.version>
         <mysql.connector.version>5.1.47</mysql.connector.version>
-        <mariadb.connector.version>2.3.0</mariadb.connector.version>
+        <mariadb.connector.version>2.2.0</mariadb.connector.version>
 
         <postgresql.connector.version>42.2.5</postgresql.connector.version>
 


[openjpa] 01/05: OPENJPA-2713 add java8 time support for MySQL and MariaDB

Posted by st...@apache.org.
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 362474e5c93fc0dd73907e16929f55450d9d92e1
Author: Mark Struberg <st...@apache.org>
AuthorDate: Fri Jan 25 21:37:16 2019 +0100

    OPENJPA-2713 add java8 time support for MySQL and MariaDB
---
 .../java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java | 12 +++++++++++-
 .../java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java   | 13 ++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
index be9b51d..106bc5b 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
@@ -344,8 +344,18 @@ public class MariaDBDictionary extends DBDictionary {
 
     @Override
     public int getPreferredType(int type) {
-        if (type == Types.CLOB && !useClobs)
+        if (type == Types.CLOB && !useClobs) {
             return Types.LONGVARCHAR;
+        }
+        else if (type == Types.TIME_WITH_TIMEZONE) {
+            // MariaDB doesn't support SQL-2003 'WITH TIMEZONE' nor the respective JDBC types.
+            return Types.TIME;
+        }
+        else if (type == Types.TIMESTAMP_WITH_TIMEZONE) {
+            // MariaDB doesn't support SQL-2003 'WITH TIMEZONE' nor the respective JDBC types.
+            return Types.TIMESTAMP;
+        }
+
         return super.getPreferredType(type);
     }
 
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
index 4d061f2..ccd63d4 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
@@ -366,11 +366,22 @@ public class MySQLDictionary
 
     @Override
     public int getPreferredType(int type) {
-        if (type == Types.CLOB && !useClobs)
+        if (type == Types.CLOB && !useClobs) {
             return Types.LONGVARCHAR;
+        }
+        else if (type == Types.TIME_WITH_TIMEZONE) {
+            // MySQL doesn't support SQL-2003 'WITH TIMEZONE' nor the respective JDBC types.
+            return Types.TIME;
+        }
+        else if (type == Types.TIMESTAMP_WITH_TIMEZONE) {
+            // MySQL doesn't support SQL-2003 'WITH TIMEZONE' nor the respective JDBC types.
+            return Types.TIMESTAMP;
+        }
+
         return super.getPreferredType(type);
     }
 
+
     /**
      * Append XML comparison.
      *


[openjpa] 04/05: formatting only

Posted by st...@apache.org.
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 e908a9c293394cfe3651fdd1f046b4b99ce5fee8
Author: Mark Struberg <st...@apache.org>
AuthorDate: Mon Jan 28 13:01:16 2019 +0100

    formatting only
---
 .../src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java | 7 +++----
 .../openjpa/persistence/criteria/TestTypeSafeCondExpression.java   | 5 ++---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
index ccd63d4..f71425e 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
@@ -156,11 +156,11 @@ public class MySQLDictionary
         }));
 
         requiresSearchStringEscapeForLike = true;
+
         // MySQL requires double-escape for strings
         searchStringEscape = "\\\\";
 
-        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED",
-            "ZEROFILL" }));
+        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED", "ZEROFILL" }));
 
         setLeadingDelimiter(DELIMITER_BACK_TICK);
         setTrailingDelimiter(DELIMITER_BACK_TICK);
@@ -356,8 +356,7 @@ public class MySQLDictionary
         throws SQLException {
         // if the user has set a get-blob strategy explicitly or the driver
         // does not automatically deserialize, delegate to super
-        if (useGetBytesForBlobs || useGetObjectForBlobs
-            || !driverDeserializesBlobs)
+        if (useGetBytesForBlobs || useGetObjectForBlobs || !driverDeserializesBlobs)
             return super.getBlobObject(rs, column, store);
 
         // most mysql drivers deserialize on getObject
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypeSafeCondExpression.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypeSafeCondExpression.java
index 920aa11..f2d6062 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypeSafeCondExpression.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypeSafeCondExpression.java
@@ -330,8 +330,7 @@ public class TestTypeSafeCondExpression extends CriteriaTest {
     }
 
     public void testLowerFunc2() {
-        String query = "select e.age From CompUser e where LOWER(e.name)" +
-        		" ='ugo'";
+        String query = "select e.age From CompUser e where LOWER(e.name) ='ugo'";
         CriteriaQuery<Integer> q = cb.createQuery(Integer.class);
         Root<CompUser> e = q.from(CompUser.class);
         q.where(cb.equal(cb.lower(e.get(CompUser_.name)), "ugo"));
@@ -342,7 +341,7 @@ public class TestTypeSafeCondExpression extends CriteriaTest {
 
     public void testUpperFunc1() {
         String query = "select UPPER(e.name) From CompUser e WHERE " +
-        		"e.computerName='PC'";
+                       "e.computerName='PC'";
         CriteriaQuery<String> q = cb.createQuery(String.class);
         Root<CompUser> e = q.from(CompUser.class);
         q.select(cb.upper(e.get(CompUser_.name)));


[openjpa] 05/05: OPENJPA-2713 add LocalDate support for Oracle DB

Posted by st...@apache.org.
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 be62c5a1230e73902ace4d7056a2b6287d10105a
Author: Mark Struberg <st...@apache.org>
AuthorDate: Tue Jan 29 13:02:05 2019 +0100

    OPENJPA-2713 add LocalDate support for Oracle DB
    
    Oracle does still not support native LocalDate, etc in their JDBC driver.
    So we have to treat it like the old datatypes.
---
 .../apache/openjpa/jdbc/sql/OracleDictionary.java  | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
index 79190cb..b58b55e 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
@@ -34,6 +34,11 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Timestamp;
 import java.sql.Types;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -192,6 +197,7 @@ public class OracleDictionary
         varbinaryTypeName = "BLOB";
         longVarbinaryTypeName = "BLOB";
         timeTypeName = "DATE";
+        timeWithZoneTypeName = "DATE";
         varcharTypeName = "VARCHAR2{0}";
         fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{
             "LONG RAW", "RAW", "LONG", "REF",
@@ -540,8 +546,9 @@ public class OracleDictionary
      */
     private boolean requiresSubselectForRange(long start, long end,
         boolean distinct, SQLBuffer order) {
-    	if (!isUsingRange(start, end))
-    		return false;
+        if (!isUsingRange(start, end)) {
+            return false;
+        }
         return isUsingOffset(start) || distinct || isUsingOrderBy(order);
     }
 
@@ -763,8 +770,7 @@ public class OracleDictionary
      * Convert an object from its proprietary Oracle type to the standard
      * Java type.
      */
-    private static Object convertFromOracleType(Object obj,
-        String convertMethod)
+    private static Object convertFromOracleType(Object obj, String convertMethod)
         throws SQLException {
         try {
             Method m = obj.getClass().getMethod(convertMethod, (Class[]) null);
@@ -820,6 +826,22 @@ public class OracleDictionary
         return cols;
     }
 
+    /**
+     * Oracle JDBC is still Java7 at most :(
+     */
+    @Override
+    public int getPreferredType(int type) {
+        switch (type) {
+            case Types.TIME_WITH_TIMEZONE:
+                return Types.TIME;
+            case Types.TIMESTAMP_WITH_TIMEZONE:
+                return Types.TIMESTAMP;
+            default:
+                return type;
+        }
+    }
+
+
     @Override
     public PrimaryKey[] getPrimaryKeys(DatabaseMetaData meta,
         String catalog, String schemaName, String tableName, Connection conn)