You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Mark Struberg (Jira)" <ji...@apache.org> on 2021/04/08 12:51:00 UTC

[jira] [Commented] (OPENJPA-2863) java.time.LocalDateTime in Oracle gets rounded to just 3 digits

    [ https://issues.apache.org/jira/browse/OPENJPA-2863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17317158#comment-17317158 ] 

Mark Struberg commented on OPENJPA-2863:
----------------------------------------

The constant {{LocalTime.MAX}} uses {{999999999}} for nanoseconds and your column is only {{TIMESTAMP(6)}} thus the value gets rounded up. That part is actually ok.

But I found another bug which is likely very related. Even the following code will round over to the next day:
{noformat}
// zero out the nanos part and truncate to micros essentially: 
awayUntil = LocalDate.of(2021, 4, 8).atTime(LocalTime.of(23, 59, 59, 666666000);
{noformat}
This is is the result of a bug we introduced a long time ago and also affects our handling of {{java.sql.Timestamp}}. We round those values to MILLIS and not to MICROS which is the default for Oracle.

I gonna fix that in {{OracleDictionary}}, for retaining the old 3 fraction digits behaviour one can use the  configuration in persistence.xml properties section to use 1_000_000 nanosecond precision:
{noformat}
<property name="openjpa.jdbc.Dictionary" value="(datePrecision=1000000)"/> {noformat}

> java.time.LocalDateTime in Oracle gets rounded to just 3 digits
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2863
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2863
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 3.1.2
>            Reporter: Karl Grosse
>            Assignee: Mark Struberg
>            Priority: Major
>
> Having a column like
>   
> {code:java}
>     @NotNull
>     @Column(name = "awayUntil", nullable = false)
>     private LocalDateTime awayUntil;
> {code}
> which we set to
> {code:java}
> awayUntil = LocalDate.of(2021, 4, 8).atTime(LocalTime.MAX);
> {code}
> gets somehow rounded to 2021-4-9 00:00:00,000000 after persisting into the Oracle DB.
> The type of the column in Oracle is Timestamp(6).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)