Can Neo4J OGM handle loading and saving a sub-graph?


(Jari) #1

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.


(Jiropole) #2

Recently when my team asked to write an entire subgraph in one piece, I created a DB extension for the purpose. While you can do some pretty sophisticated work just in cypher, sometimes you want to use the native traversal available via JVM. When dealing with schema-like subgraph creation, it's best to do define/expose it in one transaction, but yeah it takes some special maneuvers to pull that off, in my experience.