I have a problem when I try to retrieve two nodes with the same label (the same type) and a relathioship between both whit spring data.
I did a query for get the last one, like that:
@Query("MATCH (b1:Block)-[rel]->(b2) " +
"WHERE NOT (b1)<-[]-() " +
"RETURN *; ")
Block findLast();
And the Block attributes are:
@GraphId
private Long id;
private String hash;
@Relationship(direction = Relationship.OUTGOING)
private Block predecessor;
The problem is that the ogm says that there is two results (I supose b1 and b2), and throw this exception:
Caused by: java.lang.RuntimeException: Result not of expected size. Expected 1 row but found 2
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.queryForObject(ExecuteQueriesDelegate.java:73) ~[neo4j-ogm-core-2.1.5.jar:na]
at org.neo4j.ogm.session.Neo4jSession.queryForObject(Neo4jSession.java:382) ~[neo4j-ogm-core-2.1.5.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
I understand that the OGM can not choise what node is returned in the @Query method, because find two nodes of the same type, but how can I fill the second one into the first one??
Thanks!!!!