I have the query below. I want to know how to generate same query with cypher-dsl.
MATCH (m:Movie) WHERE m.name = "star"
RETURN DISTINCT m,
[(m)<-[:HAS_RELATION]-(n:AnotherNode) | n] as othersnodes
I could not find a Java API for this.
A little bit verbose, but I think this way it is better understandable.
var movieNode = Cypher.node("Movie").named("m");
var anotherNode = Cypher.node("AnotherNode").named("n");
var condition = movieNode.property("name").eq(Cypher.literalOf("star"));
var patternComprehension = Cypher.listBasedOn(movieNode.relationshipFrom(anotherNode, "HAS_RELATION")).returning(anotherNode);
var statement = Cypher.match(movieNode)
.where(condition)
.returningDistinct(movieNode.getRequiredSymbolicName(), patternComprehension.as("othersnodes"));