Examples of MongoMappingContext


Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  public void setMongo(Mongo mongo) throws Exception {

    CustomConversions conversions = new CustomConversions(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)));
    mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    mappingContext.initialize();

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mappingConverter.setCustomConversions(conversions);
    mappingConverter.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

   * @throws ClassNotFoundException
   */
  @Bean
  public MongoMappingContext mongoMappingContext() throws ClassNotFoundException {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(getInitialEntitySet());
    mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder());
    mappingContext.setFieldNamingStrategy(fieldNamingStrategy());

    return mappingContext;
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

    when(barToDBObjectConverter.convert(any(Bar.class))).thenReturn(new BasicDBObject());
    when(dbObjectToBarConverter.convert(any(DBObject.class))).thenReturn(new Bar());

    CustomConversions conversions = new CustomConversions(Arrays.asList(barToDBObjectConverter, dbObjectToBarConverter));

    context = new MongoMappingContext();
    context.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(Foo.class, Bar.class)));
    context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    context.initialize();

    converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), context);
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  MappingMongoConverter converter;

  @Before
  public void setupMongoConverter() {

    MongoMappingContext mappingContext = new MongoMappingContext();
    DbRefResolver factory = mock(DbRefResolver.class);

    converter = new MappingMongoConverter(factory, mappingContext);
    converter.afterPropertiesSet();
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(XObject.class)));
    mappingContext.initialize();

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mappingConverter.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  }

  private static final MongoConverter getDefaultMongoConverter(MongoDbFactory factory) {

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
    converter.afterPropertiesSet();
    return converter;
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(ValueObject.class)));
    mappingContext.initialize();

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mappingConverter.afterPropertiesSet();
    this.mongoTemplate = new MongoTemplate(factory, mappingConverter);
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Mock MongoDbFactory factory;

  @Before
  public void setUp() {

    this.context = new MongoMappingContext();

    this.converter = new MappingMongoConverter(new DefaultDbRefResolver(factory), context);
    this.converter.afterPropertiesSet();

    this.mapper = new QueryMapper(converter);
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Before
  public void setUp() {

    when(operations.getConverter()).thenReturn(converter);

    this.converter = new MappingMongoConverter(factory, new MongoMappingContext());
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  DbRefResolver resolver;

  @Before
  public void setUp() {

    this.context = new MongoMappingContext();
    this.resolver = new DefaultDbRefResolver(factory);
    this.converter = new MappingMongoConverter(resolver, context);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.