use of org.springframework.data.mongodb.core.convert.DbRefResolver 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.DbRefResolver in project spring-data-mongodb by spring-projects.
the class PartTreeMongoQueryUnitTests method setUp.
@Before
public void setUp() {
mappingContext = new MongoMappingContext();
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mock(MongoDbFactory.class));
MongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContext);
doReturn(converter).when(mongoOperationsMock).getConverter();
doReturn(findOperationMock).when(mongoOperationsMock).query(any());
}
use of org.springframework.data.mongodb.core.convert.DbRefResolver in project spring-boot by spring-projects.
the class MongoDataAutoConfiguration method mappingMongoConverter.
@Bean
@ConditionalOnMissingBean(MongoConverter.class)
public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory, MongoMappingContext context, BeanFactory beanFactory, CustomConversions conversions) {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context);
mappingConverter.setCustomConversions(conversions);
return mappingConverter;
}
use of org.springframework.data.mongodb.core.convert.DbRefResolver in project cas by apereo.
the class MongoDbConnectionFactory method mappingMongoConverter.
private MappingMongoConverter mappingMongoConverter(final MongoDbFactory mongoDbFactory) {
final DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
final MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, this.mongoMappingContext());
converter.setCustomConversions(customConversions);
converter.afterPropertiesSet();
return converter;
}
use of org.springframework.data.mongodb.core.convert.DbRefResolver in project spring-data-mongodb by spring-projects.
the class MongoTemplateTests method setMongo.
@Autowired
public void setMongo(Mongo mongo) throws Exception {
CustomConversions conversions = new MongoCustomConversions(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, PersonWithIdPropertyOfTypeBigInteger.class, PersonWithIdPropertyOfPrimitiveInt.class, PersonWithIdPropertyOfTypeLong.class, PersonWithIdPropertyOfPrimitiveLong.class, PersonWithIdPropertyOfTypeUUID.class)));
mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
mappingContext.initialize();
DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
mappingConverter.setCustomConversions(conversions);
mappingConverter.afterPropertiesSet();
this.mappingTemplate = new MongoTemplate(factory, mappingConverter);
}
Aggregations