neo4j - SDN 4 - Neo4jOperation.convert() deprecated -
with sdn 3 possible use neo4joperations.convert(object value, class type) convert results cypher query returns iterable<map<string, object>> neo4j domain class (annotated @nodeentity). example:
map<string,object> results = repository.findsomething("john"); for(map<string,object> row : results) { person person = neo4joperations.convert(row.get("person"), person.class); ... } // repository method @query("match (person:person)-[rel]->(node) person.firstname = {firstname} return distinct person, count(rel) order count(rel)" iterable<map<string,object>> findsomething(@param("firstname") string firstname);
as t convert(object value, class type) no longer exists in neo4joperations in sdn 4, what's equivalence in sdn 4?
http://docs.spring.io/spring-data/neo4j/docs/4.0.0.m1/reference/html/#reference_programming_model_simple-mapping doesn't cover how mapping/conversion done explicitly or implicitly.
i'm using snapshots build.
any appreciated.
as luanne suggests, you'll need in 2 steps @ moment. repository method try instead:
@query("match (p:person)-[rel]->(node) p.firstname = {firstname} return distinct p order count(rel)") iterable<person> findsomething(@param("firstname") string firstname);
this should return person
entities want in correct order, although appreciate actual count won't mapped you'd have issue second query find count, unfortunately.
if don't need actual person
entities rather properties of these nodes, work-around may map @queryresult
object instead. this:
@query("match (p:person)-[rel]->(node) p.firstname = {firstname} return distinct p.firstname, p.surname, p.dateofbirth, count(rel) rank order rank") iterable<personqueryresult> findsomething(@param("firstname") string firstname);
...where personqueryresult
pojo annotated @queryresult
setters/getters corresponding properties listed in query's return clause.
Comments
Post a Comment