Hello
I am currently trying to migrate from a previous version of SDN to SDN 6. It has been working for normal return types so far. At the moment I am stuck at trying to return a list of objects (generics) with Neo4jClient.
Example:
@Override
public List<House> getHouses(String ownerId) {
String cypherQuery = "MATCH (h:House)-[r:OWNED_BY]-(o:Owner {id: $ownerId})"
+ " RETURN collect(DISTINCT {"
+ " id: h.id,"
+ " ownerId: $ownerId,"
+ " streetName: h.street,"
+ " postalCode: h.postalCode"
+ " }) as houses";
return neo4jClient.query(cypherQuery)
.bind(ownerId).to("ownerId")
.fetchAs(????)
.mappedBy((typeSystem, record) -> record.get("houses").asList(r ->
House.builder()
.id(r.get("id").asString()
.ownerId(r.get("ownerId").asString()
.streetName(r.get("streetName").asString()
.postalCode(r.get("postalCode").asString()
.build()
)).one().orElseThrow());
}
Beware that this is a simplified example and in the actual project I would like to avoid having to make a new class just to host the list of objects as its only property.
The Problem lies on line 12. What type can I put in the fetchAs() method, so it doesn't complain about the type of List that it's being given? I've tried just using "List.class" and while that works, the IDE warns me about
"Expected: List, Received: List"
Thanks.