Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1695

Interface projection with native query not working for boolean (mysql)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.6 (Moore SR6)
    • Fix Version/s: None
    • Component/s: Mapping / Conversion
    • Labels:
      None
    • Environment:
      Spring Boot 2.2.6., JDK1.8.0.144, Windows 10 64bit, MySQL Connector 8.0.13, MySQL 8.0.15

      Description

      Simplified test case:

      Projection interface:

      public interface TestDto {
       Long getId();
       Boolean getTest();
      }

      Query with projection:

      @Query(value = "select 1 id, true test", nativeQuery = true)
      List<TestDto> test();

      Boolean property "test" is not recognized as Boolean but as Byte. Calling getTest() throws this exception:

      java.lang.IllegalArgumentException: Projection type must be an interface!

      The projection is working if the boolean field is selected directly from a table, but not, when the field is "calculated".

      More workarounds are possible, in my case change "Boolean getTest()" to "Byte getTest()" is the best.

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            anaq Michal Ondrovic
            Last updater:
            Michal Ondrovic
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: