Showing results for 
Search instead for 
Did you mean: 

SDN 6.2 RelationshipModel

Node Link

Hi there,

We are migrating from sdn 5.3 to sdn 6.2

We have a Graph Entity, where we need to pull nodes and edges from the db.

public class GraphQueryResult {
    List<Node> nodes;

    List<RelationshipModel> edges;

The edges are of type org.neo4j.ogm.response.model.RelationshipModel;

We want to remove the ogm dependency.

Is there an equivalent model in sdn 6.2?

thanks in advance



Some context: Those classes are intermediate mapping classes and were never officially supported to end in model definitions.
In SDN 6 there is no need for those classes to exist because the Java driver's types will get directly converted into the target entities and their properties.
Furthermore we don't support generic aggregations in SDN 6 actively on the level of repositories or Neo4jTemplate. Those mapping abstractions orient themselves strictly on the given business entity definition.

You can see, that there is some work to do to migrate this but it is -depending if my interpretation is right- not impossible and in the end even a little bit cleaner.
You can make use of the Neo4jClient to issue Cypher statements and map the results.

neo4jClient.query("MATCH ... return collect(node) as nodes, collect(relationship) as rels")
		.mappedBy((typeSystem, record) -> {
			MyNodes nodes = record.get("nodes").asList(node -> MyNode.from(node));
			MyRelationship rels = record.get("rels").asList(rel -> MyRelationship.from(rel));
			return new MyAggregation(nodes, relationships);

The Neo4jClient will respect Spring @Transactional as the repository and the Neo4jTemplate would do. Also it brings a minimal fluent API layer on top of the driver API that gives you the possibility to define the mapping as needed for your nodes an relationships. Additionally you get access to the typeSystem of the Java driver if you need more information about a returned field.
I did the custom naming with the prefixed My... intentionally to show that you have the freedom to use your own, maybe even more business focused, classes here.

Thank you very much for the answer.