Class CouchbaseMappingContext
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>
org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext
- All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, ApplicationContextAware, ApplicationEventPublisherAware, EnvironmentAware, MappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>
public class CouchbaseMappingContext
extends AbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>
implements ApplicationContextAware
Default implementation of a
MappingContext for Couchbase using
BasicCouchbasePersistentEntity and BasicCouchbasePersistentProperty as primary abstractions.- Author:
- Michael Nitschinger, Michael Reiche
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<BasicCouchbasePersistentEntity<?>> addPersistentEntity(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cachedprotected <T> BasicCouchbasePersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) Creates a concrete entity based out of the type information passed.protected CouchbasePersistentPropertycreatePersistentProperty(Property property, BasicCouchbasePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) Creates a concrete property based on the field information and entity.getPersistentEntity(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached.booleanvoidsetApplicationContext(ApplicationContext applicationContext) Sets (or overrides) the current application context.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetAutoIndexCreation(boolean autoCreateIndexes) voidsetFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) Configures theFieldNamingStrategyto be used to determine the field name if no manual mapping is applied.voidsetIndexCreator(CouchbasePersistentEntityIndexCreator indexCreator) capture the indexCreator when it has been added as a listener. only publishEvent() if the indexCreator hasn't already seen the class.Methods inherited from class AbstractMappingContext
addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setBeanFactory, setEnvironment, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, setStrict, shouldCreatePersistentEntityFor, shouldCreatePropertiesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MappingContext
getRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntity
-
Constructor Details
-
CouchbaseMappingContext
public CouchbaseMappingContext()
-
-
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.
-
createPersistentEntity
protected <T> BasicCouchbasePersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) Creates a concrete entity based out of the type information passed.- Specified by:
createPersistentEntityin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Type Parameters:
T- the type for the corresponding type information.- Parameters:
typeInformation- type information of the entity to create.- Returns:
- the constructed entity.
-
createPersistentProperty
protected CouchbasePersistentProperty createPersistentProperty(Property property, BasicCouchbasePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) Creates a concrete property based on the field information and entity.- Specified by:
createPersistentPropertyin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Parameters:
property- the property descriptor.owner- the entity which owns the property.simpleTypeHolder- the type holder.- Returns:
- the constructed property.
-
setApplicationContext
Sets (or overrides) the current application context.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Overrides:
setApplicationContextin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Parameters:
applicationContext- the application context to be assigned.- Throws:
BeansException- if the context can not be set properly.
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware- Overrides:
setApplicationEventPublisherin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>
-
isAutoIndexCreation
public boolean isAutoIndexCreation() -
setAutoIndexCreation
public void setAutoIndexCreation(boolean autoCreateIndexes) -
addPersistentEntity
protected Optional<BasicCouchbasePersistentEntity<?>> addPersistentEntity(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached- Overrides:
addPersistentEntityin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Parameters:
typeInformation- - entity type
-
getPersistentEntity
override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached. Instead, user our own addPersistEntity that will.- Specified by:
getPersistentEntityin interfaceMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Overrides:
getPersistentEntityin classAbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>- Parameters:
typeInformation- - entity type
-
setIndexCreator
capture the indexCreator when it has been added as a listener. only publishEvent() if the indexCreator hasn't already seen the class.- Parameters:
indexCreator-
-