List of usage examples for org.springframework.data.mongodb.core.convert DefaultDbRefResolver DefaultDbRefResolver
public DefaultDbRefResolver(MongoDbFactory mongoDbFactory)
From source file:com.avanza.ymer.TestSpaceMongoConverterFactory.java
public MongoConverter createMongoConverter() { return new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), new MongoMappingContext()); }
From source file:example.mirror.ExampleMirrorFactory.java
static MongoConverter createMongoConverter(MongoDbFactory mongoDbFactory) { DbRefResolver dbRef = new DefaultDbRefResolver(mongoDbFactory); MappingMongoConverter converter = new MappingMongoConverter(dbRef, new MongoMappingContext()); List<Converter<?, ?>> converters = new ArrayList<>(); converters.add(new FruitToBson()); converters.add(new BsonToFruit()); converter.setCustomConversions(new CustomConversions(converters)); converter.afterPropertiesSet();//from www. j a va2s . com return converter; }
From source file:proposal.MongoDbConfiguration.java
/** * Custom mongo mapping converter that fires afterload and after convert events when dealing with DBRef * @return/* w w w .ja va 2s . c o m*/ * @throws IOException */ @Bean public MappingMongoConverter mongoMappingConverter() throws IOException { MappingMongoConverter converter = new CustomMappingMongoConverter(new DefaultDbRefResolver(dbFactory), mongoMappingContext()); return converter; }
From source file:com.tlantic.integration.authentication.AuthServerMain.java
@Bean public MappingMongoConverter mongoConverter() throws Exception { MongoMappingContext mappingContext = new MongoMappingContext(); DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory); MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mappingContext); mongoConverter.setCustomConversions(customConversions()); return mongoConverter; }
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:io.leishvl.core.config.MongoConfiguration.java
@Override @Bean/*from w w w . ja v a 2s. c o m*/ public MappingMongoConverter mappingMongoConverter() throws Exception { final DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory()); final MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext()); converter.setCustomConversions(customConversions()); /* converter.setMapKeyDotReplacement("\\+"); is not needed since the custom conversions perform * this tasks in the required fields, avoiding unnecessary operations */ return converter; }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.mongo.MongoConfiguration.java
public @Bean MongoTemplate categoriesMongoTemplate() throws Exception { MongoClient client;/*from www. j a va 2 s.com*/ 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); }
From source file:com.epam.ta.reportportal.config.MongodbConfiguration.java
@Bean public MappingMongoConverter mappingMongoConverter() throws UnknownHostException { MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory()), mongoMappingContext());//w ww .jav a2s .c o m converter.setCustomConversions(customConversions()); return converter; }
From source file:org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStore.java
@Override public void afterPropertiesSet() throws Exception { if (this.mongoTemplate == null) { if (this.mappingMongoConverter == null) { this.mappingMongoConverter = new MappingMongoConverter( new DefaultDbRefResolver(this.mongoDbFactory), new MongoMappingContext()); this.mappingMongoConverter.setApplicationContext(this.applicationContext); List<Object> customConverters = new ArrayList<Object>(); customConverters.add(new MessageToBinaryConverter()); customConverters.add(new BinaryToMessageConverter()); this.mappingMongoConverter.setCustomConversions(new CustomConversions(customConverters)); this.mappingMongoConverter.afterPropertiesSet(); }//from ww w . j av a 2 s .c o m this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mappingMongoConverter); } this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.applicationContext); IndexOperations indexOperations = this.mongoTemplate.indexOps(this.collectionName); indexOperations.ensureIndex(new Index(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC)); indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC) .on(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC).unique()); indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC) .on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.DESC) .on(MessageDocumentFields.SEQUENCE, Sort.Direction.DESC)); }