1

Edited: I also tested in the version 2.6.4 and still happens

I just upgraded spring-boot from 2.5.7 to 2.6.1 and I notice a change of behavior in a specific query. I'm trying to load only a specific column in a query, and when it's value in DB is null, it is throwing the Couldn't find PersistentEntity for type class java.lang.String! Exception.

This is my code in the Repository,

@Query("SELECT my_column " +
            " FROM mytable  " +
            " WHERE another_column = :secColumn " +
            " AND third_column = :thirdColumn")
    Optional<String> getMyColumn(@Param("secColumn") String secColumn, 
                                 @Param("thirdColumn") String thirdColumn);
}

Observations:

  • It works fine if the column it DB is not null

  • It was working fine with a null value in DB for version 2.5.7

  • If I return the whole entity inside the Optional, it works as expected

aquilesb
  • 2,182
  • 1
  • 19
  • 19
  • 1
    Can be a bug on 2.6.1. Try either 2.6.0 or 2.6.4 instead to see if the problem continues. There is something in Spring Data release notes related https://github.com/spring-projects/spring-data-relational/releases/tag/2.2.9. – pringi Mar 02 '22 at 13:20
  • Just tested in the 2.6.4 and the same exception is thrown – aquilesb Mar 02 '22 at 23:03
  • That would be a regression. Could you create an issue, with a reproducer? https://github.com/spring-projects/spring-data-relational/issues/new – Jens Schauder Mar 03 '22 at 08:59
  • @JensSchauder sure, I just have done https://github.com/spring-projects/spring-data-relational/issues/1190 – aquilesb Mar 03 '22 at 11:59

1 Answers1

1

This is a bug in Spring Data JDBC which was already reported (and fixed).

The next set of releases should include that fix.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348