Class Neo4jMappingContext
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<Neo4jPersistentEntity<?>,Neo4jPersistentProperty>
org.springframework.data.neo4j.core.mapping.Neo4jMappingContext
- All Implemented Interfaces:
Aware
,InitializingBean
,ApplicationContextAware
,ApplicationEventPublisherAware
,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
Modifier and TypeClassDescriptionstatic class
A builder for creating custom instances of aNeo4jMappingContext
. -
Constructor Summary
ConstructorDescriptionNeo4jMappingContext
(Neo4jConversions neo4jConversions) Neo4jMappingContext
(Neo4jConversions neo4jConversions, org.neo4j.driver.types.TypeSystem typeSystem) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionaddPersistentEntity
(TypeInformation<?> typeInformation) static Neo4jMappingContext.Builder
builder()
protected <T> Neo4jPersistentEntity<?>
createPersistentEntity
(TypeInformation<T> typeInformation) protected Neo4jPersistentProperty
createPersistentProperty
(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) <T extends IdGenerator<?>>
Optional<T>getIdGenerator
(String reference) getInstantiatorFor
(PersistentEntity<?, ?> entity) getNodeDescription
(Class<?> underlyingClass) Retrieves a node's description by its underlying class.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.getPersistentEntity
(TypeInformation<?> typeInformation) boolean
hasCustomWriteTarget
(Class<?> targetType) <T> T
invokePostLoad
(Neo4jPersistentEntity<T> entity, T instance) Executes all post load methods of the given instance.void
setApplicationContext
(ApplicationContext applicationContext) void
setStrict
(boolean strict) We need to set the context to non-strict in case we must dynamically add parent classes.Methods inherited from class org.springframework.data.mapping.context.AbstractMappingContext
addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setApplicationEventPublisher, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, shouldCreatePersistentEntityFor, 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
Methods inherited from interface org.springframework.data.neo4j.core.mapping.Schema
getRequiredBinderFunctionFor, getRequiredMappingFunctionFor, getRequiredNodeDescription, getRequiredNodeDescription
-
Constructor Details
-
Neo4jMappingContext
public Neo4jMappingContext() -
Neo4jMappingContext
-
Neo4jMappingContext
@API(status=INTERNAL, since="6.0") @Deprecated(since="6.3.7", forRemoval=true) public Neo4jMappingContext(Neo4jConversions neo4jConversions, @Nullable org.neo4j.driver.types.TypeSystem typeSystem) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()
This API is primarily used from inside the CDI extension to configure the type system. This is necessary as we don't get notified of the context viasetApplicationContext(ApplicationContext applicationContext)
.- Parameters:
neo4jConversions
- The conversions to be usedtypeSystem
- The current drivers type system. If this is null, we use the default one without accessing the driver.
-
-
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:
setStrict
in classAbstractMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty> - Parameters:
strict
- The new value for the strict setting.
-
getEntityConverter
- Specified by:
getEntityConverter
in interfaceSchema
- Returns:
- The (reading and writing) converter used to read records into entities and write entities into maps.
-
getConversionService
-
getInstantiatorFor
-
hasCustomWriteTarget
-
createPersistentEntity
- Specified by:
createPersistentEntity
in classAbstractMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty>
-
createPersistentProperty
protected Neo4jPersistentProperty createPersistentProperty(Property property, Neo4jPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) - Specified by:
createPersistentProperty
in classAbstractMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty>
-
getNodeDescription
Description copied from interface:Schema
Retrieves a node's description by its primary label.- Specified by:
getNodeDescription
in interfaceSchema
- Parameters:
primaryLabel
- The primary label under which the node is described- Returns:
- The description if any, null otherwise
-
getNodeDescription
Description copied from interface:Schema
Retrieves a node's description by its underlying class.- Specified by:
getNodeDescription
in interfaceSchema
- Parameters:
underlyingClass
- The underlying class of the node description to be retrieved- Returns:
- The description if any, null otherwise
-
getPersistentEntity
- Specified by:
getPersistentEntity
in interfaceMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty> - Overrides:
getPersistentEntity
in classAbstractMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty>
-
addPersistentEntity
- Overrides:
addPersistentEntity
in classAbstractMappingContext<Neo4jPersistentEntity<?>,
Neo4jPersistentProperty>
-
getOrCreateIdGeneratorOfType
Description copied from interface:Schema
Creates 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:
getOrCreateIdGeneratorOfType
in interfaceSchema
- Parameters:
idGeneratorType
- The type of the ID generator to return- Returns:
- The id generator.
-
getIdGenerator
- Specified by:
getIdGenerator
in interfaceSchema
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Overrides:
setApplicationContext
in 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
-
builder()