content: package com.bol.system.cached;
  
  import com.bol.crypt.CryptVault;
  import com.bol.secure.CachedEncryptionEventListener;
  import com.bol.system.MongoDBConfiguration;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.mongodb.MongoDatabaseFactory;
  import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
  import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
  import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
  import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
  
  @Configuration
  public class CachedMongoDBConfiguration extends MongoDBConfiguration {
      @Bean
      public CachedEncryptionEventListener encryptionEventListener(CryptVault cryptVault) {
          return new CachedEncryptionEventListener(cryptVault);
      }
  
      @Override
      @Bean
      public MappingMongoConverter mappingMongoConverter(MongoDatabaseFactory databaseFactory, MongoCustomConversions customConversions, MongoMappingContext mappingContext) {
          MappingMongoConverter converter = super.mappingMongoConverter(databaseFactory, customConversions, mappingContext);
          // NB: without overriding defaultMongoTypeMapper, an _class field is put in every document
          // since we know exactly which java class a specific document maps to, this is surplus
          converter.setTypeMapper(new DefaultMongoTypeMapper(null));
          return converter;
      }
  }
  