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

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

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

OPENJPA-2849 fix UnaryOp to use DBDictionary

UnaryOps should use the DBDictionary to resolve the requested data whenever 
possible.
Previously we always have been requesting JDBC native types when doing max(), 
min(), etc.
But this returns values of types which we potentially cannot handle.


> 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.1.3
>
>
> 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)

Reply via email to