Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2849

select(max) etc of LocalDate, LocalDateTime etc leads to ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.2
    • 3.2.0
    • jdbc
    • None

    Description

      The following code leads to a ClassCastException:

              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);
      
      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)
      

      Attachments

        Activity

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: