When I run the following query in my browser
MATCH (a:Attribute)--(c:Class {name: 'Dog'})--(b:Attribute) RETURN a.name as nom1,c.name as nom2,b.name as nom3
I have results :
╒════════╤══════╤════════╕
│"nom1" │"nom2"│"nom3" │
╞════════╪══════╪════════╡
│"gender"│"Dog" │"age" │
├────────┼──────┼────────┤
│"age" │"Dog" │"gender"│
└────────┴──────┴────────┘
When I use the session.query()
with Result
type as follows:
String query = "MATCH (a:Attribute)--(c:Class {name: 'Dog'})--(b:Attribute) RETURN a.name as nom1,c.name as nom2,b.name as nom3";
Result result = session.query(query, new HashMap<>());
I have the following results [{nom3=age, nom2=Dog, nom1=gender}, {nom3=gender, nom2=Dog, nom1=age}]
.
Then, I want to use a custom DTO to get theses results directly mapped into a Java object as follows:
public class TestResult {
String nom1;
String nom2;
String nom3;
}
String query = "MATCH (a:Attribute)--(c:Class {name: 'Dog'})--(b:Attribute) RETURN a.name as nom1,c.name as nom2,b.name as nom3";
Iterable<TestResult> testResultList = session.query(TestResult.class, query, new HashMap<>());
for(TestResult testResult : testResultList){
System.out.println("-------------------------------");
System.out.println(testResult.toString());
}
This session.query() call with the TestResult object does not return anything, the Iterable is empty. Do you have an idea how where the problem is?
When debugging the session.query() call, I see that the database returns the results, but that somehow they are not mapped to my TestResult objects.