本文整理汇总了Java中org.springframework.data.mongodb.core.convert.MongoConverter类的典型用法代码示例。如果您正苦于以下问题:Java MongoConverter类的具体用法?Java MongoConverter怎么用?Java MongoConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MongoConverter类属于org.springframework.data.mongodb.core.convert包,在下文中一共展示了MongoConverter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mappingMongoConverter
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(MongoConverter.class)
public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory,
MongoMappingContext context, BeanFactory beanFactory) {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
context);
try {
mappingConverter
.setCustomConversions(beanFactory.getBean(CustomConversions.class));
}
catch (NoSuchBeanDefinitionException ex) {
// Ignore
}
return mappingConverter;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MongoDataAutoConfiguration.java
示例2: CustomMongodbSerializer
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
/**
* Creates a new {@link CustomMongodbSerializer} for the given {@link MappingContext}.
*
* @param converter must not be {@literal null}.
*/
public CustomMongodbSerializer(MongoConverter converter) {
Assert.notNull(converter, "MongoConverter must not be null!");
this.mappingContext = converter.getMappingContext();
this.converter = converter;
this.mapper = new QueryMapper(converter);
}
示例3: convertEntityToJson
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
/**
* Serializes an object into a string format that can be inserted into a MongoDB collection.
*
* @param entity
* @return
*/
public String convertEntityToJson(Object entity){
MongoConverter converter = mongoTemplate.getConverter();
DBObject dbObject = new BasicDBObject();
converter.write(entity, dbObject);
if (dbObject.containsField("_id") && dbObject.get("_id") == null){
dbObject.removeField("_id");
}
if (dbObject.containsField("_class")){
dbObject.removeField("_class");
}
return dbObject.toString();
}
示例4: mongoConverter
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean(name = "mappingConverter")
public MongoConverter mongoConverter(MongoDbFactory mongoDbFactory) {
MappingMongoConverter mappingMongoConverter =
new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), new MongoMappingContext());
return mappingMongoConverter;
}
示例5: mongoTemplate
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MongoTemplate mongoTemplate(MongoDbFactory mongoDbFactory,
MongoConverter converter) throws UnknownHostException {
return new MongoTemplate(mongoDbFactory, converter);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:MongoDataAutoConfiguration.java
示例6: getDefaultMongoConverter
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
private MongoConverter getDefaultMongoConverter(MongoDbFactory factory) {
MappingMongoConverter converter = new MappingMongoConverter(factory, new MongoMappingContext());
converter.afterPropertiesSet();
converter.setTypeMapper(new DefaultMongoTypeMapper(null));
return converter;
}
示例7: MongoTemplateWithRetry
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
public MongoTemplateWithRetry(MongoDbFactory dbFactory, MongoConverter mongoConverter) {
super(dbFactory, mongoConverter);
}
示例8: MongoEntityTemplate
import org.springframework.data.mongodb.core.convert.MongoConverter; //导入依赖的package包/类
public MongoEntityTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
super(mongoDbFactory, mongoConverter);
this.mapper = new QueryMapper(mongoConverter);
mappingContext = mongoConverter.getMappingContext();
}