diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/convert/DataConversionServiceFactory.java b/data-runtime/src/main/java/io/micronaut/data/runtime/convert/DataConversionServiceFactory.java index a42c227dbce..e52fb64b439 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/convert/DataConversionServiceFactory.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/convert/DataConversionServiceFactory.java @@ -634,6 +634,9 @@ DataConversionServiceImpl build(@NonNull BeanContext beanContext) { // ZonedDateTime addZonedConvertorsConvertors(conversionService, ZonedDateTime.class, Function.identity()); + // LocalDate + conversionService.addConverter(LocalDate.class, java.sql.Date.class, java.sql.Date::valueOf); + // LocalTime conversionService.addConverter(LocalTime.class, Timestamp.class, localTime -> Timestamp.valueOf(localTime.atDate(LocalDate.now()))); conversionService.addConverter(LocalTime.class, Instant.class, localTime -> localTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()).toInstant()); diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/QueryStatement.java b/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/QueryStatement.java index 09db30b420c..af60dda2895 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/QueryStatement.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/QueryStatement.java @@ -100,7 +100,7 @@ default QueryStatement setDynamic( if (value instanceof Date date) { return setDate(statement, index, date); } else { - return setDate(statement, index, convertRequired(value, Date.class)); + return setDate(statement, index, convertRequired(value, java.sql.Date.class)); } case TIMESTAMP: Instant instant; diff --git a/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy b/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy index 8f7d10df9bd..c55a31ea82e 100644 --- a/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy +++ b/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy @@ -486,6 +486,7 @@ abstract class AbstractRepositorySpec extends Specification { retrievedBook.offsetDateTime == book.offsetDateTime retrievedBook.dateCreated == book.dateCreated retrievedBook.dateUpdated == book.dateUpdated + retrievedBook.localDate == book.localDate // stored as a DATE type without time // retrievedBookProj.date == book.date