-2

I would like to load a sub-graph from Neo4J database and use OGM for automatic mapping into entities. After that I wish to change content of some of the entities, and finally the entities should be mapped back into an updated sub-graph that should be saved into the database.

For example, given the model in https://neo4j.com/docs/ogm-manual/current/tutorial/: e.g. four "Subjects" are given and the sub-graph of interest contains all "Teacher"s "Class"es and "Student"s, which are related via the selected "Subject"s.

Is it possible to load and save sub-graphs with Neo4J and OGM? Pointers to documentation and examples are welcomed.

JAQ
  • 1

1 Answers1

1

The link you've posted is the documentation: https://neo4j.com/docs/ogm-manual/current/tutorial/

Once you've configured the OGM, obtain a reference to a Session via a SessionFactory and load entities to whatever depth you require using load or query methods. These are mapped by the OGM onto your domain objects. Then, you simply modify them as required, and persist them back to the graph. The depth controls how many levels of related entities are loaded/saved i.e. the subgraph.

See tutorial code samples here: https://github.com/neo4j-examples/neo4j-ogm-university

Luanne
  • 19,145
  • 1
  • 39
  • 51