use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project commons-dao by reportportal.
the class MongodbConfiguration method mappingMongoConverter.
@Bean
public MappingMongoConverter mappingMongoConverter() throws UnknownHostException {
MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory()), mongoMappingContext());
converter.setCustomConversions(customConversions());
return converter;
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method setUp.
@Before
public void setUp() throws SecurityException, NoSuchMethodException {
context = new MongoMappingContext();
DbRefResolver resolver = new DefaultDbRefResolver(mock(MongoDbFactory.class));
converter = new MappingMongoConverter(resolver, context);
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class UnwrapAndReadDocumentCallbackUnitTests method setUp.
@Before
public void setUp() {
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslatorMock);
MongoTemplate template = new MongoTemplate(factory);
MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(factory), new MongoMappingContext());
this.callback = template.new UnwrapAndReadDocumentCallback(converter, Target.class, "collection-1");
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-integration by spring-projects.
the class AbstractConfigurableMongoDbMessageStore method afterPropertiesSet.
@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 MongoCustomConversions(customConverters));
this.mappingMongoConverter.afterPropertiesSet();
}
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));
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-boot by spring-projects.
the class MongoDatabaseFactoryDependentConfiguration method mappingMongoConverter.
@Bean
@ConditionalOnMissingBean(MongoConverter.class)
MappingMongoConverter mappingMongoConverter(MongoDatabaseFactory factory, MongoMappingContext context, MongoCustomConversions conversions) {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context);
mappingConverter.setCustomConversions(conversions);
return mappingConverter;
}
Aggregations