Our entire team is trying to set up our own Converters for Spring Data Mongo and having problems with it.
It feels that Spring never calls for registerConvertersIn on CustomConversions and therefore our custom converters are overridden. AbstractMongoConfiguration#customConversions never become part of conversion.
Currently, Spring Data Mongo 1.6.3 is being used, but it to be a problem for 1.8.0 too as I I've checked calls to CustomConversions#registerConvertersIn and found none.
I did fix this problem by calling CustomConversions#registerConvertersIn in custom MappingMongoConverter like this:
class MongoConfig extends AbstractMongoConfiguration {
@Bean
@Override
public MappingMongoConverter mappingMongoConverter() throws Exception {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory());
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext()) {
@Override
public void setCustomConversions(CustomConversions conversions) {
super.setCustomConversions(conversions);
conversions.registerConvertersIn(conversionService);
}
};
converter.setCustomConversions(customConversions());
return converter;
}
}
Are we committing any mistake over here?