Class Neo4jMappingContext
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
org.springframework.data.neo4j.core.mapping.Neo4jMappingContext
- All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, ApplicationContextAware, ApplicationEventPublisherAware, EnvironmentAware, MappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>, Schema
@API(status=STABLE,
since="6.0")
public final class Neo4jMappingContext
extends AbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
implements Schema
An implementation of both a
Schema as well as a Neo4j version of Spring Data's
MappingContext. It is recommended to
provide the initial set of classes through AbstractMappingContext.setInitialEntitySet(Set).- Since:
- 6.0
- Author:
- Michael J. Simons, Gerrit Meier
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder for creating custom instances of aNeo4jMappingContext. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPersistentEntity(TypeInformation<?> typeInformation) static Neo4jMappingContext.Builderbuilder()protected <T> Neo4jPersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) protected Neo4jPersistentPropertycreatePersistentProperty(Property property, Neo4jPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) createStatementForImperativeRelationshipsWithPropertiesBatch(boolean isNew, Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipDescription, Object relatedValues, List<Map<String, Object>> relationshipPropertiesRows, boolean canUseElementId) createStatementForImperativeSimpleRelationshipBatch(Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipDescription, List<Object> plainRelationshipRows, boolean canUseElementId) createStatementForSingleRelationship(Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipContext, Object relatedValue, boolean isNewRelationship, boolean canUseElementId) Returns the (reading and writing) converter used to read records into entities and write entities into maps.<T extends IdGenerator<?>>
Optional<T> getIdGenerator(String reference) getInstantiatorFor(PersistentEntity<?, ?> entity) @Nullable NodeDescription<?> getNodeDescription(Class<?> underlyingClass) Retrieves a node's description by its underlying class.@Nullable NodeDescription<?> getNodeDescription(String primaryLabel) Retrieves a node's description by its primary label.<T extends IdGenerator<?>>
TgetOrCreateIdGeneratorOfType(Class<T> idGeneratorType) Creates or retrieves an instance of the given id generator class.@Nullable Neo4jPersistentEntity<?> getPersistentEntity(TypeInformation<?> typeInformation) booleanhasCustomWriteTarget(Class<?> targetType) <T> TinvokePostLoad(Neo4jPersistentEntity<T> entity, T instance) Executes all post load methods of the given instance.voidsetApplicationContext(ApplicationContext applicationContext) voidsetStrict(boolean strict) We need to set the context to non-strict in case we must dynamically add parent classes.Methods inherited from class AbstractMappingContext
addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setApplicationEventPublisher, setBeanFactory, setEnvironment, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, shouldCreatePersistentEntityFor, shouldCreatePropertiesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MappingContext
getRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntityMethods inherited from interface Schema
getRequiredBinderFunctionFor, getRequiredMappingFunctionFor, getRequiredNodeDescription, getRequiredNodeDescription
-
Constructor Details
-
Neo4jMappingContext
public Neo4jMappingContext() -
Neo4jMappingContext
-
-
Method Details
-
builder
-
setStrict
public void setStrict(boolean strict) We need to set the context to non-strict in case we must dynamically add parent classes. As there is no way to access the original value without reflection, we track its change.- Overrides:
setStrictin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>- Parameters:
strict- the new value for the strict setting
-
getEntityConverter
Description copied from interface:SchemaReturns the (reading and writing) converter used to read records into entities and write entities into maps.- Specified by:
getEntityConverterin interfaceSchema- Returns:
- the entity converter for the schema
-
getConversionService
-
getInstantiatorFor
-
hasCustomWriteTarget
-
createPersistentEntity
- Specified by:
createPersistentEntityin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
-
createPersistentProperty
protected Neo4jPersistentProperty createPersistentProperty(Property property, Neo4jPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) - Specified by:
createPersistentPropertyin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
-
getNodeDescription
Description copied from interface:SchemaRetrieves a node's description by its primary label.- Specified by:
getNodeDescriptionin interfaceSchema- Parameters:
primaryLabel- the primary label under which the node is described- Returns:
- the description if any, null otherwise
-
getNodeDescription
Description copied from interface:SchemaRetrieves a node's description by its underlying class.- Specified by:
getNodeDescriptionin interfaceSchema- Parameters:
underlyingClass- the underlying class of the node description to be retrieved- Returns:
- the description if any, null otherwise
-
getPersistentEntity
- Specified by:
getPersistentEntityin interfaceMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>- Overrides:
getPersistentEntityin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
-
addPersistentEntity
- Overrides:
addPersistentEntityin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>
-
getOrCreateIdGeneratorOfType
Description copied from interface:SchemaCreates or retrieves an instance of the given id generator class. During the lifetime of the schema, this method returns the same instance of reoccurring requests of the same type.- Specified by:
getOrCreateIdGeneratorOfTypein interfaceSchema- Type Parameters:
T- the class type- Parameters:
idGeneratorType- the type of the ID generator to return- Returns:
- the id generator.
-
getIdGenerator
- Specified by:
getIdGeneratorin interfaceSchema
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Overrides:
setApplicationContextin classAbstractMappingContext<Neo4jPersistentEntity<?>, Neo4jPersistentProperty>- Throws:
BeansException
-
createStatementForImperativeSimpleRelationshipBatch
public CreateRelationshipStatementHolder createStatementForImperativeSimpleRelationshipBatch(Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipDescription, List<Object> plainRelationshipRows, boolean canUseElementId) -
createStatementForImperativeRelationshipsWithPropertiesBatch
public CreateRelationshipStatementHolder createStatementForImperativeRelationshipsWithPropertiesBatch(boolean isNew, Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipDescription, Object relatedValues, List<Map<String, Object>> relationshipPropertiesRows, boolean canUseElementId) -
createStatementForSingleRelationship
public CreateRelationshipStatementHolder createStatementForSingleRelationship(Neo4jPersistentEntity<?> neo4jPersistentEntity, RelationshipDescription relationshipContext, Object relatedValue, boolean isNewRelationship, boolean canUseElementId) -
invokePostLoad
Executes all post load methods of the given instance.- Type Parameters:
T- type of the entity- Parameters:
entity- the entity definitioninstance- the instance whose post load methods should be executed- Returns:
- the instance
-