Example usage for org.springframework.data.mongodb.core.convert MappingMongoConverter setTypeMapper

List of usage examples for org.springframework.data.mongodb.core.convert MappingMongoConverter setTypeMapper

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.convert MappingMongoConverter setTypeMapper.

Prototype

public void setTypeMapper(@Nullable MongoTypeMapper typeMapper) 

Source Link

Document

Configures the MongoTypeMapper to be used to add type information to Document s created by the converter and how to lookup type information from Document s when reading them.

Usage

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.mongo.MongoConfiguration.java

public @Bean MongoTemplate mongoTemplate() throws Exception {
    MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory()),
            new MongoMappingContext());
    // remove _class
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));

    return new MongoTemplate(mongoDbFactory(), converter);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.mongo.MongoConfiguration.java

public

@Bean MongoTemplate categoriesMongoTemplate() throws Exception {
    MongoClient client;//from   w ww  . j a v a 2  s .  c  om
    client = getMongoClientForCategoriesDatabase();

    MongoDbFactory categoriesMongoDbFactory = new SimpleMongoDbFactory(client, database);
    MappingMongoConverter converter = new MappingMongoConverter(
            new DefaultDbRefResolver(categoriesMongoDbFactory), new MongoMappingContext());
    // remove _class
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));

    return new MongoTemplate(categoriesMongoDbFactory, converter);
}