java.time.LocalDate not supported in native queries by latest Spring Data/Hibernate?

It looks like you found a gap in the converters. Spring Data converts out of the box between java.util.Date and java.time.LocalDate but not between java.time.LocalDate and java.sql.Date and other date and time-related types in the java.sql package.

You can create your own converter to do that. You can use Jsr310JpaConverters as a template.

Also, you might want to create a feature request and if you build a converter for your use, you might even submit a pull request.


I know this is an older question, but my solution to this problem does not require a custom converter.

    public interface BirthdayRepository<T, ID extends Serializable> extends Repository<T, ID> {
      @Query(value = "select cast(day as date) from birthdays", nativeQuery = true)
      Iterable<java.time.LocalDate> getBirthdays();
    }

The CAST tells JPQL to use available java date\time types rather than java.sql.Date