I'm running a cypher query using
org.neo4j.ogm.session.Session#query(java.lang.Class<T>, java.lang.String, java.util.Map<java.lang.String,?>)
The Class is a POJO which I have annotated using @QueryResult
@QueryResult
public class Neo4jQueryResultClip {
private String clipUuid;
private String postTitle;
private Date clipCreatedAt;
//getters and setters
}
My query cypher goes something like this
match (c:Clip) where (:User{uuid:{uuidParam}})-[:USER_FOLLOWS_USER]->(:User)-[:CLIP_BY_USER]->(c) OR (:User{uuid:{uuidParam}})-[:CLIP_BY_USER]->(c)match (c)<-[:CLIP_PRODUCT|:CLIP_INSPIRATION]-(post) optional match (c)<-[cp:CLIP_PRODUCT]-(post) return c.uuid as clipUuid,c.createdAt as clipCreatedAt,post.title as postTitle order by c.createdAt DESC
However the iterator of results returned is empty
If I run the same query using
org.neo4j.ogm.session.Session#query(java.lang.String, java.util.Map<java.lang.String,?>)
I get proper results encapsulated in the
org.neo4j.ogm.session.result.Result
object.
Is there something I am missing here? I have verified that the class Neo4jQueryResultClip is getting scanned by neo4j spring configuration I am using following versions spring-data-neo4j (4.0.0.RELEASE) and neo4j-ogm library (1.1.4)
@QueryResult
used on in Spring Data Neo4j repositories (see http://docs.spring.io/spring-data/neo4j/docs/4.0.0.RELEASE/reference/html/#reference_programming-model_mapresult) so that's why it isn't mapped.
If you do this instead inside a repository
@Query("match (c:Clip) where (:User{uuid:{uuidParam}})-[:USER_FOLLOWS_USER]->(:User)-[:CLIP_BY_USER]->(c) OR (:User{uuid:{uuidParam}})-[:CLIP_BY_USER]->(c)match (c)<-[:CLIP_PRODUCT|:CLIP_INSPIRATION]-(post) optional match (c)<-[cp:CLIP_PRODUCT]-(post) return c.uuid as clipUuid,c.createdAt as clipCreatedAt,post.title as postTitle order by c.createdAt DESC")
Neo4jQueryResultClip getClip(...);
then it should work just fine.