-
Notifications
You must be signed in to change notification settings - Fork 617
Closed
Labels
type: enhancementA general enhancementA general enhancement
Milestone
Description
We are saving a large list of nodes in Neo4j with many edges. Instead of defining the relationship as part of the node, we are saving all the nodes first and then all the edges with the Cypher query below. This reduces the number of calls to DB to 2 and improves the performance.
@Query("""
UNWIND keys($relationships) as sourceId
UNWIND $relationships[sourceId] as relationship
MATCH
(source:`package` {id: sourceId}),
(target:`package` {id: relationship.__target__.__id__})
MERGE (source)-[r:DEPENDS_ON]->(target)
SET r += relationship.__properties__
""")
Mono<Void> mergeRelationships(@Param("relationships") Map<String, List<PackageRelationshipProperties>> relationships);
However, it does not work because entities are converted only when they are in a list, not in a map (and, of course, not in a map of lists). This happens here.
A perfect solution would be to reduce the number of queries to 2 in the saveAll
method. However, if this is not possible, supporting the conversion of entities recursively will solve the problem.
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement