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) boolean
Returns whether auto-index creation is enabled or disabled.void
setApplicationContext
(ApplicationContext applicationContext) void
setAutoIndexCreation
(boolean autoCreateIndexes) Enables/disables auto-index creation.void
setFieldNamingStrategy
(FieldNamingStrategy fieldNamingStrategy) Configures theFieldNamingStrategy
to be used to determine the field name if no manual mapping is applied.protected boolean
Methods 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, shouldCreateProperties
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
-
MongoMappingContext
public MongoMappingContext()Creates a newMongoMappingContext
.
-
-
Method Details
-
setFieldNamingStrategy
Configures theFieldNamingStrategy
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
- theFieldNamingStrategy
to be used to determine the field name if no manual mapping is applied.
-
shouldCreatePersistentEntityFor
- Overrides:
shouldCreatePersistentEntityFor
in classAbstractMappingContext<MongoPersistentEntity<?>,
MongoPersistentProperty>
-
createPersistentProperty
public MongoPersistentProperty createPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) - Specified by:
createPersistentProperty
in classAbstractMappingContext<MongoPersistentEntity<?>,
MongoPersistentProperty>
-
createPersistentEntity
protected <T> BasicMongoPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) - Specified by:
createPersistentEntity
in classAbstractMappingContext<MongoPersistentEntity<?>,
MongoPersistentProperty>
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Overrides:
setApplicationContext
in 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:
getPersistentEntity
in interfaceMappingContext<MongoPersistentEntity<?>,
MongoPersistentProperty> - Overrides:
getPersistentEntity
in classAbstractMappingContext<MongoPersistentEntity<?>,
MongoPersistentProperty>
-