Spring Data DomainClassConverter nie działa (w połączeniu z Java Config)
Próbuję skonfigurować Spring Data / JPA DomainClassConverter, aby automatycznie konwertować identyfikatory (String) na same klasy domeny.
Mój projekt wykorzystuje Java Config (więc nie ma xml).
W moim WebConfig mam obecnie:
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new DomainClassConverter<DefaultFormattingConversionService>((DefaultFormattingConversionService) registry));
}
}
Wydaje się, że połączenie DomainClassConverter zostało pomyślnie nawiązane, ponieważ widzę to w usłudze konwersji podczas drukowania:
ConversionService converters =
..<default converters>..
org.springframework.data.repository.support.DomainClassConverter@6ea4ce0d, org.springframework.core.convert.support.IdToEntityConverter@5d3f03b, org.springframework.core.convert.support.ObjectToObjectConverter@1d40b47a
Jednak przy przesyłaniu zagnieżdżonego formularza (zamówienie z podpisem klienta) klient nie jest automatycznie konwertowany, a zatem otrzymuję:
Failed to convert property value of type java.lang.String to required type org.mycomp.domain.Customer for property customer; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.mycomp.domain.Customer] for property customer: no matching editors or conversion strategy found
Zastanawiam się, czy robię tu coś złego?