I cannot resolve modelMapper error. Do you have any ideas where is the issue?
NB: In view java.sql.Time doesn\'t have non-argument constructor I didn\'t find the better
I am not sure how it was with ModelMapper
when question was asked but using converter should be straightforward. Instead of implementing a converter for the whole class implement it to the types that actually need conversion. So like:
public static Converter<LocalTime, Time> timeConverter = new AbstractConverter<>() {
@Override
protected Time convert(LocalTime source) {
return null == source ? null : Time.valueOf(source);
}
};
Then it is just to:
mm.addConverter(timeConverter);
Guess if using Spring or EJB you know howto add this into your configuration.
This resolved my problem:
modelMapper.getConfiguration().setAmbiguityIgnored(true);
try modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT)
You need to customize ModelMapper configuration during Bean initialization with the help of a PropertyMap: http://modelmapper.org/user-manual/property-mapping/
@Bean
public ModelMapper modelMapper(){
ModelMapper mm = new ModelMapper();
PropertyMap<CarWashDTO, CarWash> propertyMap = new PropertyMap<CarWashDTO, CarWash> (){
protected void configure() {
map(source.getId()).setId(null);
}
}
mm.addMappings(propertyMap);
return mm;
}