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 2021/04/09 12:27:26 UTC

[openjpa] branch master updated (683e780 -> 59a8586)

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 683e780  OPENJPA-2863 use MICROS for TIMESTAMP precision in Oracle
     new c7539a1  new oracle docker image
     new 59a8586  OPENJPA-2865 use java.time handling from JDBC driver

The 2 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:
 .../apache/openjpa/jdbc/sql/OracleDictionary.java  | 86 ++++++++++++++++++----
 pom.xml                                            | 14 +++-
 2 files changed, 86 insertions(+), 14 deletions(-)

[openjpa] 01/02: new oracle docker image

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 c7539a11715954db1b8d55789e386fa7dae0837f
Author: Mark Struberg <st...@apache.org>
AuthorDate: Fri Apr 9 14:22:53 2021 +0200

    new oracle docker image
    
    The old OracleX11 was plagued with connection problems,
    which seems to be a known problem with that version.
---
 pom.xml | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6c6a3b5..55a367d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,10 @@
              anything else allows the test to execute normally
         -->
         <tests.openjpa.allowfailure>ignore</tests.openjpa.allowfailure>
+
+        <!-- By default we use DBCP2 via AutoDriverDataSource -->
+        <tests.openjpa.driverDataSource>dbcp</tests.openjpa.driverDataSource>
+
         <!--turn on sources.jar generation by setting to verify and true -->
         <createSource>none</createSource>
         <createSources>false</createSources>
@@ -1504,6 +1508,9 @@
                 <oracle.server.version>latest</oracle.server.version>
                 <docker.external.oracle.port>1521</docker.external.oracle.port>
 
+                <!-- Oracle Driver + XE11 seems to not play well with DBCP2 -->
+                <tests.openjpa.driverDataSource>simple</tests.openjpa.driverDataSource>
+
                 <connection.driver.name>oracle.jdbc.driver.OracleDriver</connection.driver.name>
                 <openjpa.oracle.database>openjpatst</openjpa.oracle.database>
                 <openjpa.oracle.username>openjpatst</openjpa.oracle.username>
@@ -1541,7 +1548,8 @@
                             <images>
                                 <image>
                                     <!--<name>oracledb19c/oracle.19.3.0-ee:oracle19.3.0-ee</name>-->
-                                    <name>oracleinanutshell/oracle-xe-11g</name>
+                                    <!--<name>oracleinanutshell/oracle-xe-11g</name>-->
+                                    <name>pvargacl/oracle-xe-18.4.0:latest</name>
                                     <run>
                                         <volumes>
                                             <bind>
@@ -1934,6 +1942,10 @@
                             <name>tests.openjpa.allowfailure</name>
                             <value>${tests.openjpa.allowfailure}</value>
                         </property>
+                        <property>
+                            <name>openjpa.jdbc.DriverDataSource</name>
+                            <value>${tests.openjpa.driverDataSource}</value>
+                        </property>
                     </systemProperties>
                     </configuration>
                 </plugin>

[openjpa] 02/02: OPENJPA-2865 use java.time handling from JDBC driver

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 59a8586855b23cc38cf0c79c4ab050f9f1de7bfd
Author: Mark Struberg <st...@apache.org>
AuthorDate: Fri Apr 9 14:26:51 2021 +0200

    OPENJPA-2865 use java.time handling from JDBC driver
---
 .../apache/openjpa/jdbc/sql/OracleDictionary.java  | 86 ++++++++++++++++++----
 1 file changed, 73 insertions(+), 13 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 b3d7c17..b352908 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,10 @@ 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.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -94,6 +98,14 @@ public class OracleDictionary
     public String autoAssignSequenceName = null;
 
     /**
+     * Whether this JDBC driver has native java.time support for
+     * LocalDate, LocalDateTime, LocalTime, OffsetTime and OffsetDateTime
+     *
+     *
+     */
+    public boolean nativeJavaTimeSupport = true;
+
+    /**
      * Flag to use OpenJPA 0.3 style naming for auto assign sequence name and
      * trigger name for backwards compatibility.
      */
@@ -218,7 +230,7 @@ public class OracleDictionary
             "EXCLUSIVE", "EXISTS", "FILE", "FLOAT", "FOR", "FROM", "GRANT",
             "GROUP", "HAVING", "IDENTIFIED", "IMMEDIATE", "IN", "INCREMENT",
             "INDEX", "INITIAL", "INSERT", "INTEGER", "INTERSECT", "INTO",
-            "IS", "LEVEL", "LIKE", "LOCK", "LONG", "MAXEXTENTS", "MINUS",
+            "IS", "KEY", "LEVEL", "LIKE", "LOCK", "LONG", "MAXEXTENTS", "MINUS",
             "MODE", "NOAUDIT", "NOCOMPRESS", "NOT", "NOWAIT", "NULL", "NUMBER",
             "OF", "OFFLINE", "ON", "ONLINE", "OPTION", "OR", "ORDER", "PCTFREE",
             "PRIOR", "PRIVILEGES", "PUBLIC", "REVOKE", "ROW", "ROWS", "SELECT",
@@ -302,6 +314,10 @@ public class OracleDictionary
                     maxEmbeddedBlobSize = -1;
                     maxEmbeddedClobSize = -1;
                 }
+                if (jdbcMajor < 18) {
+                    // no native java.time support for old JDBC drivers.
+                    nativeJavaTimeSupport = false;
+                }
                 String productVersion = meta.getDatabaseProductVersion()
                     .split("Release ",0)[1].split("\\.",0)[0];
                 int release = Integer.parseInt(productVersion);
@@ -648,18 +664,18 @@ public class OracleDictionary
         Column col)
         throws SQLException {
 
-    	//We need a place to detect if the user is setting the 'supportsSetClob' property.
-    	//While in previous releases this property had meaning, it is no longer useful
-    	//given the code added via OPENJPA-1691.  As such, we need to warn user's the
-    	//property no longer has meaning.  While it would be nice to have a better way
-    	//to detect if the supportsSetClob property has been set, the best we can do
-    	//is detect the variable in this code path as this is the path a user's code
-    	//would go down if they are still executing code which actually made use of
-    	//the support provided via setting supportsSetClob.
-    	if (supportsSetClob && logSupportsSetClobWarning){
-    		log.warn(_loc.get("oracle-set-clob-warning"));
-    		logSupportsSetClobWarning=false;
-    	}
+        //We need a place to detect if the user is setting the 'supportsSetClob' property.
+        //While in previous releases this property had meaning, it is no longer useful
+        //given the code added via OPENJPA-1691.  As such, we need to warn user's the
+        //property no longer has meaning.  While it would be nice to have a better way
+        //to detect if the supportsSetClob property has been set, the best we can do
+        //is detect the variable in this code path as this is the path a user's code
+        //would go down if they are still executing code which actually made use of
+        //the support provided via setting supportsSetClob.
+        if (supportsSetClob && logSupportsSetClobWarning){
+            log.warn(_loc.get("oracle-set-clob-warning"));
+            logSupportsSetClobWarning=false;
+        }
 
         if (col.isXML()) {
             if (isJDBC4) {
@@ -705,6 +721,46 @@ public class OracleDictionary
     }
 
     @Override
+    public void setLocalDate(PreparedStatement stmnt, int idx, LocalDate val, Column col) throws SQLException {
+        stmnt.setObject(idx, val);
+    }
+
+    @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);
+    }
+
+    @Override
+    public OffsetDateTime getOffsetDateTime(ResultSet rs, int column) throws SQLException {
+        return rs.getObject(column, OffsetDateTime.class);
+    }
+
+    @Override
     public String getClobString(ResultSet rs, int column)
         throws SQLException {
         if (_driverBehavior != BEHAVE_ORACLE)
@@ -831,6 +887,10 @@ public class OracleDictionary
      */
     @Override
     public int getPreferredType(int type) {
+        if (nativeJavaTimeSupport) {
+            return type;
+        }
+
         switch (type) {
             case Types.TIME_WITH_TIMEZONE:
                 return Types.TIME;