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/01 15:03:17 UTC

[openjpa] branch master updated (f187178 -> c3bbb92)

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 f187178  fix a test to also work with MSSQL
     new 93fe064  Also disable for Oracle
     new 5b46dcc  connection handling fixed
     new 20faa36  fix OpenJPA and PostgreSQL docker setup
     new c3bbb92  OPENJPA-2854 fix OffsetTime handling for PostgreSQL

The 4 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:
 .../openjpa/jdbc/sql/PostgresDictionary.java       | 26 ++++++++++++++++++++
 .../openjpa/jdbc/meta/strats/AbstractLobTest.java  |  3 +--
 .../openjpa/jdbc/oracle/TestOracleXmlColumn.java   |  5 ++--
 openjpa-project/BUILDING.txt                       |  6 +++--
 pom.xml                                            | 28 +++++-----------------
 src/test/sql/oracle-docker/init.sql                |  5 +++-
 6 files changed, 43 insertions(+), 30 deletions(-)

[openjpa] 01/04: Also disable for Oracle

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 93fe0643006b53d23e10931aabcdda4bf3df6ee2
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Apr 1 16:45:37 2021 +0200

    Also disable for Oracle
    
    Oracle also closes the JDBC Stream.
    Most likely all other DBs now do it as well.
---
 .../test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
index 7653463..95ef6d6 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
@@ -50,8 +50,7 @@ public abstract class AbstractLobTest extends SingleEMFTestCase {
     protected static boolean firstTestExecuted;
 
     protected List<Class<?>> supportedDatabases =
-        new ArrayList<>
-            (Arrays.asList(MySQLDictionary.class, OracleDictionary.class, DB2Dictionary.class));
+        new ArrayList<>(Arrays.asList(MySQLDictionary.class, DB2Dictionary.class));
 
     @Override
     public void setUp() throws Exception {

[openjpa] 02/04: connection handling fixed

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 5b46dcc191a0cb104013f59c60a61c572bd756f3
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Apr 1 16:46:42 2021 +0200

    connection handling fixed
    
    Connection was set to autoCommit, so no commit or rollback possible
---
 .../java/org/apache/openjpa/jdbc/oracle/TestOracleXmlColumn.java     | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/oracle/TestOracleXmlColumn.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/oracle/TestOracleXmlColumn.java
index 6dadba3..bb693dc 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/oracle/TestOracleXmlColumn.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/oracle/TestOracleXmlColumn.java
@@ -32,6 +32,7 @@ import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
 
+
 public class TestOracleXmlColumn extends AbstractPersistenceTestCase {
 
     private static String projectStr = "project";
@@ -62,14 +63,13 @@ public class TestOracleXmlColumn extends AbstractPersistenceTestCase {
         // the mapping tool doesn't handle creating XML columns that map to strings
         // build table manually
         Connection con = ((DataSource) conf.getConnectionFactory()).getConnection();
+        con.setAutoCommit(true);
         Statement stmt = con.createStatement();
         String ddl = "DROP TABLE XmlColEntity";
         try {
             stmt.execute(ddl);
-            con.commit();
         } catch (SQLException se) {
             // assume the table did not exist.
-            con.rollback();
         }
 
         ddl =
@@ -78,7 +78,6 @@ public class TestOracleXmlColumn extends AbstractPersistenceTestCase {
         stmt.execute(ddl);
         String insertSql = "INSERT into XmlColEntity (ID, XMLCOLUMN, VERSION) VALUES (42, '" + xmlData + "', 1)";
         stmt.execute(insertSql);
-        con.commit();
 
         stmt.close();
         con.close();

[openjpa] 03/04: fix OpenJPA and PostgreSQL docker setup

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 20faa3692c701052d510909d09c00abeae9a468a
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Apr 1 16:50:49 2021 +0200

    fix OpenJPA and PostgreSQL docker setup
---
 openjpa-project/BUILDING.txt        |  6 ++++--
 pom.xml                             | 28 ++++++----------------------
 src/test/sql/oracle-docker/init.sql |  5 ++++-
 3 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/openjpa-project/BUILDING.txt b/openjpa-project/BUILDING.txt
index e75d6cf..8144675 100644
--- a/openjpa-project/BUILDING.txt
+++ b/openjpa-project/BUILDING.txt
@@ -201,7 +201,7 @@ For running against a MySQL Docker installation:
  -ea -Dopenjpa.ConnectionDriverName=com.mysql.jdbc.Driver -Dopenjpa.ConnectionURL=jdbc:mysql://localhost:3306/openjpatst -Dopenjpa.ConnectionUserName=openjpatst -Dopenjpa.ConnectionPassword=openjpatst
 
 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
+ -ea -Dopenjpa.ConnectionDriverName=org.postgresql.Driver -Dopenjpa.ConnectionURL=jdbc:postgresql://localhost:5432/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
@@ -215,7 +215,9 @@ For running against a hsqldb based installation:
 For running tests against a Microsoft SQLServer Docker based installation:
  -ea -Dopenjpa.ConnectionDriverName=com.microsoft.sqlserver.jdbc.SQLServerDriver -Dopenjpa.ConnectionURL=jdbc:sqlserver://localhost:1433;sendTimeAsDatetime=false -Dopenjpa.ConnectionUserName=SA -Dopenjpa.ConnectionPassword=OpenJP8tst
 
-TODO: finish!
+For running against a Oracle Docker installation:
+ -ea -Dopenjpa.ConnectionDriverName=oracle.jdbc.driver.OracleDriver -Dopenjpa.ConnectionURL=jdbc:oracle:thin:@localhost:1521:xe -Dopenjpa.ConnectionUserName=openjpatst -Dopenjpa.ConnectionPassword=openjpatst
+
 
 For starting tests in `openjpa-persistence-jdbc` inside a compiler you can also trigger all the enhancement manually via:
 
diff --git a/pom.xml b/pom.xml
index 583d793..ba7b43d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
         <hsqldb.version>2.4.1</hsqldb.version>
         <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>
+        <postgresql.connector.version>42.2.9</postgresql.connector.version>
         <mssql.connector.version>9.2.1.jre8</mssql.connector.version>
 
         <!-- other common versions -->
@@ -1496,12 +1496,9 @@
                 </property>
             </activation>
             <properties>
-                <!-- by default we use the Atlassian 3rd Party repo, which contains the dependency -->
-                <oracle.maven.repo>https://packages.atlassian.com/maven-3rdparty/</oracle.maven.repo>
-
-                <oracle.groupid>com.oracle</oracle.groupid>
-                <oracle.artifactid>ojdbc6</oracle.artifactid>
-                <oracle.version>11.2.0.4.0-atlassian-hosted</oracle.version>
+                <oracle.groupid>com.oracle.ojdbc</oracle.groupid>
+                <oracle.artifactid>ojdbc8</oracle.artifactid>
+                <oracle.version>19.3.0.0</oracle.version>
 
                 <oracle.server.version>latest</oracle.server.version>
                 <docker.external.oracle.port>1521</docker.external.oracle.port>
@@ -1533,20 +1530,6 @@
                 </dependency>
             </dependencies>
 
-            <repositories>
-                <repository>
-                    <id>oracle.repository</id>
-                    <name>Oracle Repository</name>
-                    <url>${oracle.maven.repo}</url>
-                    <layout>default</layout>
-                    <snapshots>
-                        <enabled>false</enabled>
-                    </snapshots>
-                    <releases>
-                        <enabled>true</enabled>
-                    </releases>
-                </repository>
-            </repositories>
 
             <build>
                 <plugins>
@@ -1556,7 +1539,8 @@
                         <configuration>
                             <images>
                                 <image>
-                                    <name>sath89/oracle-12c:${oracle.server.version}</name>
+                                    <!--<name>oracledb19c/oracle.19.3.0-ee:oracle19.3.0-ee</name>-->
+                                    <name>oracleinanutshell/oracle-xe-11g</name>
                                     <run>
                                         <volumes>
                                             <bind>
diff --git a/src/test/sql/oracle-docker/init.sql b/src/test/sql/oracle-docker/init.sql
index 8886510..e26f3d4 100644
--- a/src/test/sql/oracle-docker/init.sql
+++ b/src/test/sql/oracle-docker/init.sql
@@ -25,4 +25,7 @@
 CREATE USER openjpatst IDENTIFIED BY openjpatst;
 GRANT CONNECT, RESOURCE, DBA TO openjpatst;
 GRANT CREATE SESSION GRANT ANY PRIVILEGE TO openjpatst;
-GRANT UNLIMITED TABLESPACE TO  openjpatst;
\ No newline at end of file
+GRANT UNLIMITED TABLESPACE TO  openjpatst;
+
+-- to avoid ORA-12519, TNS:no appropriate service handler found
+alter system set processes=250 scope=spfile;
\ No newline at end of file

[openjpa] 04/04: OPENJPA-2854 fix OffsetTime handling for PostgreSQL

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 c3bbb92557743928d045e1061360f3bfd48b182e
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Apr 1 17:02:25 2021 +0200

    OPENJPA-2854 fix OffsetTime handling for PostgreSQL
    
    PostgreSQL doesn't natively support OffsetTime. While it has a column type
    time with time zone it actually only stores the time as UTC time.
---
 .../openjpa/jdbc/sql/PostgresDictionary.java       | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
index 644442a..a1d6ce9 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
@@ -38,6 +38,8 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashSet;
@@ -750,6 +752,30 @@ public class PostgresDictionary extends DBDictionary {
         return rs.getObject(column, OffsetDateTime.class);
     }
 
+    /**
+     * default column type for OffsetTime is 'time with time zone'.
+     * But opposed to the name PostgreSQL internally stores those values in UTC time
+     * without any timezone.
+     */
+    @Override
+    public void setOffsetTime(PreparedStatement stmnt, int idx, OffsetTime val, Column col) throws SQLException {
+        // this is really a whacky hack somehow
+        // PostgreSQL doesn't support OffsetTime natively.
+        // The JDBC driver will automatically convert this to UTC which is the
+        // internal normalised TimeZone PostgreSQL uses.
+        LocalTime utcTime = val.withOffsetSameInstant(OffsetDateTime.now().getOffset()).toLocalTime();
+        stmnt.setTime(idx, java.sql.Time.valueOf(utcTime));
+    }
+
+    @Override
+    public OffsetTime getOffsetTime(ResultSet rs, int column) throws SQLException {
+        final java.sql.Time utcTime = rs.getTime(column);
+        if (utcTime != null) {
+            return utcTime.toLocalTime().atOffset(OffsetDateTime.now().getOffset());
+        }
+        return null;
+    }
+
     @Override
     public void setLocalDate(PreparedStatement stmnt, int idx, LocalDate val, Column col) throws SQLException {
         stmnt.setObject(idx, val);