Build Neo4J Graph from Json in Spring -


i'm wondering best way create graph in neo4j json using spring. imagine have simple nodeentity person:

@nodeentity public class person {   private set<person> friends; } 

i want build graph of friendships between persons json object like:

{   persons: [     {name:"fritz", friend:["hans"]},     {name:"hans", friends:["fritz", "georg"]},     {name:"georg", friends:["hans"]}   ] } 

can use spring data rest apis de-serialize json directly node entities , relations?

good question, in past tried write sd-rest single entities, not entities relationships.

i write own rest-controller , transform json correct objects.

you use cypher directly , pass json root parameter json cypher.

unwind {json}.persons person // merge = get-or-create merge (p:person {name:person.name}) unwind person.friends friend // because friend can come earlier friend person merge (f:person {name:friend.name}) // merge on relationship make sure exists once, no matter direction merge (p)-[:knows]-(f) 

this query part of sdn repository or called via neo4jtemplate or -session.

in sdn4 can use created directly domain objects.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -