@Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    CustomConversions conversions =
        new CustomConversions(
            Arrays.asList(DateToDateTimeConverter.INSTANCE, DateTimeToDateConverter.INSTANCE));

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(
        new HashSet<Class<?>>(
            Arrays.asList(
                PersonWith_idPropertyOfTypeObjectId.class,
                PersonWith_idPropertyOfTypeString.class,
                PersonWithIdPropertyOfTypeObjectId.class,
                PersonWithIdPropertyOfTypeString.class,
                PersonWithIdPropertyOfTypeInteger.class,
                PersonWithIdPropertyOfPrimitiveInt.class,
                PersonWithIdPropertyOfTypeLong.class,
                PersonWithIdPropertyOfPrimitiveLong.class)));
    mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    mappingContext.afterPropertiesSet();

    MappingMongoConverter mappingConverter = new MappingMongoConverter(factory, mappingContext);
    mappingConverter.setCustomConversions(conversions);
    mappingConverter.afterPropertiesSet();

    this.mappingTemplate = new MongoTemplate(factory, mappingConverter);
  }
  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(ValueObject.class)));
    mappingContext.afterPropertiesSet();

    MappingMongoConverter mappingConverter = new MappingMongoConverter(factory, mappingContext);
    mappingConverter.afterPropertiesSet();
    this.mongoTemplate = new MongoTemplate(factory, mappingConverter);
  }