Mark Struberg created OPENJPA-2849:
--------------------------------------

             Summary: 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
             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