尝试使用@QueryResult 映射到 POJO 时,密码查询未返回结果
cypher query is not returning the results when trying to use @QueryResult to map to POJO
我正在 运行使用
进行密码查询
org.neo4j.ogm.session.Session#query(java.lang.Class<T>, java.lang.String, java.util.Map<java.lang.String,?>)
Class 是我使用 @QueryResult
注释的 POJO
@QueryResult
public class Neo4jQueryResultClip {
private String clipUuid;
private String postTitle;
private Date clipCreatedAt;
//getters and setters
}
我的查询密码是这样的
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
但是返回结果的迭代器是空的
如果我 运行 使用
相同的查询
org.neo4j.ogm.session.Session#query(java.lang.String, java.util.Map<java.lang.String,?>)
我得到了封装在
中的正确结果
org.neo4j.ogm.session.result.Result
对象。
这里有我遗漏的东西吗?
我已经验证 class Neo4jQueryResultClip 正在被 neo4j spring 配置扫描
我正在使用以下版本
spring-data-neo4j (4.0.0.RELEASE) 和 neo4j-ogm 库 (1.1.4)
@QueryResult
在 Spring Data Neo4j 存储库中使用(参见 http://docs.spring.io/spring-data/neo4j/docs/4.0.0.RELEASE/reference/html/#reference_programming-model_mapresult),所以这就是它未映射的原因。
如果您在存储库中执行此操作
@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(...);
那么它应该可以正常工作。
我正在 运行使用
进行密码查询org.neo4j.ogm.session.Session#query(java.lang.Class<T>, java.lang.String, java.util.Map<java.lang.String,?>)
Class 是我使用 @QueryResult
注释的 POJO@QueryResult
public class Neo4jQueryResultClip {
private String clipUuid;
private String postTitle;
private Date clipCreatedAt;
//getters and setters
}
我的查询密码是这样的
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
但是返回结果的迭代器是空的
如果我 运行 使用
相同的查询org.neo4j.ogm.session.Session#query(java.lang.String, java.util.Map<java.lang.String,?>)
我得到了封装在
中的正确结果org.neo4j.ogm.session.result.Result
对象。
这里有我遗漏的东西吗? 我已经验证 class Neo4jQueryResultClip 正在被 neo4j spring 配置扫描 我正在使用以下版本 spring-data-neo4j (4.0.0.RELEASE) 和 neo4j-ogm 库 (1.1.4)
@QueryResult
在 Spring Data Neo4j 存储库中使用(参见 http://docs.spring.io/spring-data/neo4j/docs/4.0.0.RELEASE/reference/html/#reference_programming-model_mapresult),所以这就是它未映射的原因。
如果您在存储库中执行此操作
@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(...);
那么它应该可以正常工作。