spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
740 stars 342 forks source link

AggregateReference conversion does not honor custom converters #1750

Closed kota65535 closed 2 months ago

kota65535 commented 4 months ago

Given MySQL table schema, entity class and custom converter...

This should convert value of the binary id column into UUID id field of TaskEntity when the table is read, but the following exception is thrown.

org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Byte] to type [org.springframework.data.jdbc.core.mapping.AggregateReference<jp.co.sre.aip.samplebasic.core.app.repository.UserEntity, java.util.UUID>] for value [-121]
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:182)
    at org.springframework.core.convert.support.ArrayToObjectConverter.convert(ArrayToObjectConverter.java:68)
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:182)

...

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Byte] to type [java.util.UUID]

    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:294)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:185)
    at org.springframework.data.jdbc.core.convert.AggregateReferenceConverters$SimpleTypeToAggregateReferenceConverter.convert(AggregateReferenceConverters.java:131)
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
mp911de commented 4 months ago

Can you provide a minimal yet complete sample that reproduces the problem? You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

kota65535 commented 4 months ago

@mp911de Sure, here it is.