我正在运行一个密码查询
org.neo4j.ogm.session.Session#query(java.lang.Class<T>, java.lang.String, java.util.Map<java.lang.String,?>)
该类是我使用@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
对象。
这里有什么东西我遗漏了吗?我已经验证了类Neo4jQueryResultClip正在被我使用的neo4j弹簧配置扫描,我使用的是Spring-Data-ne4j (4.0.0.RELEASE)和新4j-ogm库(1.1.4)。
发布于 2016-02-03 15:29:24
@QueryResult
在Spring数据存储库中使用(参见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(...);
那它就能正常工作了。
https://stackoverflow.com/questions/35174698
复制相似问题