Given nodes (a:NodeA)-[r:hasCapability]->(b:NodeB) can a DTO class based projection use classes to describe NodeA and NodeB or must the DTO class be a single class and only contain primitive types when using a custom @Query?
public class NodeA {
@Id @GeneratedValue
private Long id;
String name;
String alias;
@Relationship(type = "hasCapability", direction = Direction.OUTGOING)
private List<HasCapability> hasCapabiltyList = new ArrayList<>();
}
public class NodeB {
@Id @GeneratedValue
Long id;
String capability;
@Relationship(type = "hasCapability", direction = Direction.Incoming)
private List<HasCapability> hasCapabilityList = new ArrayList<>();
}
@RelationshipProperties
public class HasCapaiblity {
@Id @GeneratedValue
Long id;
@TargetNode
NodeB nodeB;
}
Custom query to return all A and B nodes
@Query(" " +
"MATCH (a:NodeA)-[r:hasCapibilty]->(b:NodeB) " +
"RETURN a AS nodeA , b AS nodeB "
)
List<NodeDTO> findMessageTest(Long compendiumId);
Should I expect this class projection DTO work? Would the custom query projection know how to map the parameters of node A and node B?
public class NodeDTO {
NodeADTO nodeA;
NodeBDTO nodeB;
}
public class NodeADTO {
String name;
String alias;
}
public class NodeBDTO {
String capability
}