Relationships not returned in query

**I posted this in the wrong category at first, my apologies, cross post: How to get connected in Java **

I'm trying to model the electricity net, the data is structured in this way:

ElektraNodes (Label) (has objectId):

  • Transformer (Label)
  • Station (Label)
  • Etc.

ElektraLinks (Label) (has objectId and length and connections)

  • Cable (Label)
  • Rail (Label)
  • Field (Label)
  • Etc.

So for example a rail would be represented as:

{
  "identity": 142244, 
  "labels": [
    "ELink",
    "rail",
  ],
  "properties": {
"length": "15.5",
"objectId": "114999",

  }
}

This gives me working queries in the Neo4J browser, for example:

MATCH (n:rail {objectId: "114999"}) 
 CALL apoc.path.spanningTree(n, 
 {labelFilter: "/station", 
 minLevel: 1, 
 maxLevel: 100})
 YIELD path 
 WITH n, nodes(path) as node
 RETURN n, node

The above would give me the starting node with ID 114999 and all nodes returns from the path that the spanningTree gives me. Up until here that's perfect.

But now I want to return all nodes, which can be both ElektraNodes and all its subtypes, and ElektraLinks and all its subtypes, in Java.

For example I create a repository that has this:

@Repository
public interface NodeLinkRepository extends ReactiveNeo4jRepository<ELinkEntity, String> {

    @Query("MATCH (n {objectId: \"114999\"}) \n" +
            " CALL apoc.path.spanningTree(n, \n" +
            " {labelFilter: \"/station\", \n" +
            " minLevel: 1, \n" +
            " maxLevel: 100})\n" +
            " YIELD path \n" +
            " WITH n, nodes(path) as node\n" +
            " RETURN n, node")
    Flux<ELinkEntity > findPath();

Where the ELinkEntity is:

@Node("ELink")
@Data // generates setters and getters
public class ELinkEntity {

    @Id
    private String objectId;    

    @Relationship(type = "CONNECTED", direction = Outgoing)
    private Set<ENodeEntity> connected = new HashSet<>();

    private String length;
}

and I do the same for my nodes:

@Node("ENode")
@Data
public class ENodeEntity{

    @Id
    private String objectId;    
}

If I would run the above query, instead of giving me the entire path which would consist of a 100 or so objects, I only get the first object node:

[
{
"objectId": "114999",
"connected": [],
"lengte": "15.5"
},
{
"objectId": "114999",
"connected": [],
"lengte": "15.5"
}
]

So as you can see, the links and followings nodes are not part of the response, while in NEO4j browser, this returns all nodes and all links, the full path. What do I need to do in java to return the full content of the nodes?

Then for the next step, what would be the proper way to introduce the inheritance stack that I have?

I am having similar problem with

@Query("MATCH (n:{id $id})-[r]->(a:Attribute) RETURN n, COLLECT(r), COLLECT(a);")

Where the n is returned just fine, yet the relationship is not filled.