[jira] [Commented] (OPENJPA-2849) select(max) etc of LocalDate, LocalDateTime etc leads to ClassCastException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OPENJPA-2849) select(max) etc of LocalDate, LocalDateTime etc leads to ClassCastException

Mark Struberg (Jira)

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

ASF subversion and git services commented on OPENJPA-2849:
----------------------------------------------------------

Commit 25af7c35ee04fd198e95a5e3767530852a432ee6 in openjpa's branch refs/heads/master from Mark Struberg
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=25af7c3 ]

OPENJPA-2849 proper handling of different Date types


> select(max) etc of LocalDate, LocalDateTime etc leads to ClassCastException
> ---------------------------------------------------------------------------
>
>                 Key: OPENJPA-2849
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2849
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 3.1.2
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>            Priority: Major
>             Fix For: 3.2.0
>
>
> The following code leads to a ClassCastException:
> {noformat}
>         final TypedQuery<LocalDate> maxLocalDateQry = em.createQuery("select max(t.localDateField) from Java8TimeTypes AS t", LocalDate.class);
>         final LocalDate maxLocalDate = maxLocalDateQry.getSingleResult();
>         assertEquals(VAL_LOCAL_DATE, maxLocalDate);
> {noformat}
> {noformat}
> Caused by: java.lang.ClassCastException: Cannot convert object "01.01.19 00:00" of type "class java.sql.Date" into an instance of "class java.time.LocalDate".
> at org.apache.openjpa.kernel.Filters.convert(Filters.java:336)
> at org.apache.openjpa.kernel.Filters.convert(Filters.java:264)
> at org.apache.openjpa.jdbc.kernel.exps.UnaryOp.load(UnaryOp.java:142)
> {noformat}



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