[openjpa] branch master updated (0fc957a -> 683e780)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[openjpa] branch master updated (0fc957a -> 683e780)

struberg
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 0fc957a  OPENJPA-2861 fix Raw handling
     new a688353  OPENJPA-2864 use Timestamp precision from Column if set
     new 683e780  OPENJPA-2863 use MICROS for TIMESTAMP precision in Oracle

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:
 .../org/apache/openjpa/jdbc/sql/DBDictionary.java  | 27 +++++++++++++++++++++-
 .../apache/openjpa/jdbc/sql/OracleDictionary.java  |  4 ++++
 2 files changed, 30 insertions(+), 1 deletion(-)
Reply | Threaded
Open this post in threaded view
|

[openjpa] 01/02: OPENJPA-2864 use Timestamp precision from Column if set

struberg
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 a68835381e0975aa1c75cd381e5e37d63b1d0db1
Author: Mark Struberg <[hidden email]>
AuthorDate: Thu Apr 8 14:54:22 2021 +0200

    OPENJPA-2864 use Timestamp precision from Column if set
---
 .../org/apache/openjpa/jdbc/sql/DBDictionary.java  | 27 +++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
index e638d8e..a9a1030 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
@@ -313,6 +313,11 @@ public class DBDictionary
     public int maxEmbeddedBlobSize = -1;
     public int maxEmbeddedClobSize = -1;
     public int inClauseLimit = -1;
+
+    /**
+     * Attention, while this is named datePrecision it actually only get used for Timestamp handling!
+     * @see StateManagerImpl#roundTimestamp(Timestamp, int)
+     */
     public int datePrecision = MILLI;
 
     /**
@@ -1441,7 +1446,27 @@ public class DBDictionary
     public void setTimestamp(PreparedStatement stmnt, int idx, Timestamp val, Calendar cal, Column col)
         throws SQLException {
 
-        val = StateManagerImpl.roundTimestamp(val, datePrecision);
+        int usePrecision = datePrecision;
+        if (col != null) {
+            int columnPrecision = col.getPrecision();
+            if (columnPrecision >= 0) { // negative value means we don't know
+                if (columnPrecision == 0) {
+                    usePrecision = SEC;
+                }
+                else if (columnPrecision == 3) {
+                    usePrecision = MILLI;
+                }
+                else if (columnPrecision == 6) {
+                    usePrecision = MICRO;
+                }
+                else if (columnPrecision == 9) {
+                    usePrecision = NANO;
+                }
+                // rest defaults to datePrecision
+            }
+        }
+
+        val = StateManagerImpl.roundTimestamp(val, usePrecision);
 
         if (cal == null)
             stmnt.setTimestamp(idx, val);
Reply | Threaded
Open this post in threaded view
|

[openjpa] 02/02: OPENJPA-2863 use MICROS for TIMESTAMP precision in Oracle

struberg
In reply to this post by struberg
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 683e78045cba80703154207a96e5935d64a076e1
Author: Mark Struberg <[hidden email]>
AuthorDate: Thu Apr 8 14:55:28 2021 +0200

    OPENJPA-2863 use MICROS for TIMESTAMP precision in Oracle
   
    Default type for Oracle is TIMESTAMP(6) but somehow we did only
    round to 3 fraction digits in the past.
    Can be tweaked to the old value via DBDictionary config in persistence.xml
---
 .../src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java   | 4 ++++
 1 file changed, 4 insertions(+)

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 8dd0687..b3d7c17 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
@@ -193,6 +193,10 @@ public class OracleDictionary
         longVarbinaryTypeName = "BLOB";
         timeTypeName = "DATE";
         timeWithZoneTypeName = "DATE";
+
+        // default TIMESTAMP is TIMESTAMP(6) which means MICROs
+        datePrecision = MICRO;
+
         varcharTypeName = "VARCHAR2{0}";
         fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{
             "LONG RAW", "RAW", "LONG", "REF",