0

Spring provides @QueryResult annotation to map the returned values to a java object. But seems like the class annotated with @QueryResult can have only instance variables of primitive type. If it is an object then it gets mapped to Map<String, Object>.

Is there any way to map this Map<String, Object> to a java object? I tried but keep getting null value

For instance,

MATCH (n{name:'x'}) return {id: ID(n), labels: labels(n)}

Want to match return value of this query to

@QueryResult
class QueryResult{
    NodeInfo node;
}

class NodeInfo{
   Long id;
   String []labels;
}

Mapping works if class is defined as

@QueryResult
class QueryResult{
   Map<String, Object> node;
}
Luanne
  • 19,145
  • 1
  • 39
  • 51
sidgate
  • 14,650
  • 11
  • 68
  • 119

1 Answers1

1

This isn't supported- converting a Map to a POJO.

You might be able to eventually define a converter (NodeInfo<->Map) but that won't work in the current version.

Please open a feature request at https://jira.spring.io/browse/DATAGRAPH/to support converters if you'd like this item to be discussed by the team.

Luanne
  • 19,145
  • 1
  • 39
  • 51