Class MongoMappingContext

java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
org.springframework.data.mongodb.core.mapping.MongoMappingContext
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.data.mapping.context.MappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>

public class MongoMappingContext extends org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty> implements org.springframework.context.ApplicationContextAware
Default implementation of a MappingContext for MongoDB using BasicMongoPersistentEntity and BasicMongoPersistentProperty as primary abstractions.
Author:
Jon Brisbin, Oliver Gierke, Christoph Strobl
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new MongoMappingContext.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> BasicMongoPersistentEntity<T>
    createPersistentEntity(org.springframework.data.util.TypeInformation<T> typeInformation)
     
    createPersistentProperty(org.springframework.data.mapping.model.Property property, MongoPersistentEntity<?> owner, org.springframework.data.mapping.model.SimpleTypeHolder simpleTypeHolder)
     
     
    boolean
    Returns whether auto-index creation is enabled or disabled.
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    void
    setAutoIndexCreation(boolean autoCreateIndexes)
    Enables/disables auto-index creation.
    void
    setFieldNamingStrategy(org.springframework.data.mapping.model.FieldNamingStrategy fieldNamingStrategy)
    Configures the FieldNamingStrategy to be used to determine the field name if no manual mapping is applied.
    protected boolean
    shouldCreatePersistentEntityFor(org.springframework.data.util.TypeInformation<?> type)
     

    Methods inherited from class org.springframework.data.mapping.context.AbstractMappingContext

    addPersistentEntity, addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setApplicationEventPublisher, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, setStrict

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.data.mapping.context.MappingContext

    getRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntity
  • Constructor Details

  • Method Details

    • setFieldNamingStrategy

      public void setFieldNamingStrategy(@Nullable org.springframework.data.mapping.model.FieldNamingStrategy fieldNamingStrategy)
      Configures the FieldNamingStrategy to be used to determine the field name if no manual mapping is applied. Defaults to a strategy using the plain property name.
      Parameters:
      fieldNamingStrategy - the FieldNamingStrategy to be used to determine the field name if no manual mapping is applied.
    • shouldCreatePersistentEntityFor

      protected boolean shouldCreatePersistentEntityFor(org.springframework.data.util.TypeInformation<?> type)
      Overrides:
      shouldCreatePersistentEntityFor in class org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
    • createPersistentProperty

      public MongoPersistentProperty createPersistentProperty(org.springframework.data.mapping.model.Property property, MongoPersistentEntity<?> owner, org.springframework.data.mapping.model.SimpleTypeHolder simpleTypeHolder)
      Specified by:
      createPersistentProperty in class org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
    • createPersistentEntity

      protected <T> BasicMongoPersistentEntity<T> createPersistentEntity(org.springframework.data.util.TypeInformation<T> typeInformation)
      Specified by:
      createPersistentEntity in class org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Overrides:
      setApplicationContext in class org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
      Throws:
      org.springframework.beans.BeansException
    • isAutoIndexCreation

      public boolean isAutoIndexCreation()
      Returns whether auto-index creation is enabled or disabled.
      NOTE: Index creation should happen at a well-defined time that is ideally controlled by the application itself.
      Returns:
      true when auto-index creation is enabled; false otherwise.
      INFO: As of 3.x the default will is set to false was true in 2.x.
      Since:
      2.2
      See Also:
    • setAutoIndexCreation

      public void setAutoIndexCreation(boolean autoCreateIndexes)
      Enables/disables auto-index creation.
      NOTE:Index creation should happen at a well-defined time that is ideally controlled by the application itself.
      Parameters:
      autoCreateIndexes - set to true to enable auto-index creation.
      Since:
      2.2
      See Also:
    • getPersistentEntity

      @Nullable public MongoPersistentEntity<?> getPersistentEntity(MongoPersistentProperty persistentProperty)
      Specified by:
      getPersistentEntity in interface org.springframework.data.mapping.context.MappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
      Overrides:
      getPersistentEntity in class org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>