Module spring.data.mongodb
Class MongoMappingContext
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
org.springframework.data.mongodb.core.mapping.MongoMappingContext
- All Implemented Interfaces:
Aware,BeanFactoryAware,InitializingBean,ApplicationContextAware,ApplicationEventPublisherAware,EnvironmentAware,MappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
public class MongoMappingContext
extends AbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
implements 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> BasicMongoPersistentEntity<T>createPersistentEntity(TypeInformation<T> typeInformation) createPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) getPersistentEntity(MongoPersistentProperty persistentProperty) booleanReturns whether auto-index creation is enabled or disabled.voidsetApplicationContext(ApplicationContext applicationContext) voidsetAutoIndexCreation(boolean autoCreateIndexes) Enables/disables auto-index creation.voidsetFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) Configures theFieldNamingStrategyto be used to determine the field name if no manual mapping is applied.protected booleanMethods inherited from class org.springframework.data.mapping.context.AbstractMappingContext
addPersistentEntity, addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setApplicationEventPublisher, setBeanFactory, setEnvironment, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, setStrict, shouldCreatePropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.mapping.context.MappingContext
getRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntity
-
Constructor Details
-
MongoMappingContext
public MongoMappingContext()Creates a newMongoMappingContext.
-
-
Method Details
-
setFieldNamingStrategy
Configures theFieldNamingStrategyto be used to determine the field name if no manual mapping is applied. Defaults to a strategy using the plain property name.- Parameters:
fieldNamingStrategy- theFieldNamingStrategyto be used to determine the field name if no manual mapping is applied.
-
shouldCreatePersistentEntityFor
- Overrides:
shouldCreatePersistentEntityForin classAbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
-
createPersistentProperty
public MongoPersistentProperty createPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) - Specified by:
createPersistentPropertyin classAbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
-
createPersistentEntity
protected <T> BasicMongoPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) - Specified by:
createPersistentEntityin classAbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Overrides:
setApplicationContextin classAbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty> - Throws:
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:
getPersistentEntityin interfaceMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty> - Overrides:
getPersistentEntityin classAbstractMappingContext<MongoPersistentEntity<?>,MongoPersistentProperty>
-