[英]How Neo4j ogm return result set for a Cypher query?
I'm new with Neo4j OGM so I create a simple example to understand how neo4j ogm work. 我是Neo4j OGM的新手,所以我创建了一个简单的示例来了解neo4j ogm的工作方式。 I use Movie graph.
我使用电影图。
My Movie class : 我的电影课:
@NodeEntity(label="Movie")
public class Movie extends Entity {
@Property(name = "title")
private String title;
@Property(name="released")
private int released;
@Property(name="tagline")
private String tagline;
public Movie(){
}
public Movie(String titre, int year, String tagline){
this.title = titre;
this.released = year;
this.tagline = tagline;
}
@Relationship(type = "ACTED_IN", direction = Relationship.INCOMING)
private Set<Person> actors = new HashSet<Person>();
public String getTitle(){
return title;
}
public int getReleased(){
return released;
}
public void setTitle(String ptitle){
this.title = ptitle;
}
public void setReleased(int pReleased){
this.released = pReleased;
}
public String getTagline(){
return this.tagline;
}
public void setTagline(String pTagline){
this.tagline = pTagline;
}
public Set<Person> getActors(){
return this.actors;
}
public void setActors(Set<Person> actors){
this.actors = actors;
}
@Override
public String toString(){
return "Movie {" + "id=" + getLId() +
",title=" + title + ",released="+ released + ",tagline="+ tagline +"}";
}
And, I try get data form the movie graph with a simple query: 而且,我尝试通过一个简单的查询从电影图获取数据:
String query = "MATCH (p:Person {name:'Keanu Reeves'})-[r:ACTED_IN]->(m:Movie) RETURN p";
Iterable<Person> lperson = session.query(Person.class, query, Collections.emptyMap());
for (Person person : lperson) {
System.out.println(person.getName());
}
In my opinion, the result set of this query will be : "Keanu Reeves" but Neo4j Ogm give me 7 times "Keanu Reeves" : 我认为,此查询的结果集将为:“ Keanu Reeves”,但是Neo4j Ogm给我7次“ Keanu Reeves”:
So because Keanu plays in 7 movies, and then Neo4j ogm return 7 times "Keanu Reeves". 因此,因为基努(Keanu)参演了7部电影,然后Neo4j ogm返回了7次“基努·里维斯(Keanu Reeves)”。 I want to knows if my perspective is correct or not ?
我想知道我的观点是否正确吗?
Can I return a sub-graph with Neo4j-ogm using Cypher ? 我可以使用Cypher返回带有Neo4j-ogm的子图吗? ex : Keanu and all his movies, in java : person.getMovies();
例如:基努(Keanu)和他所有的电影,都在java中:person.getMovies(); If it's possible then what I need to do ?
如果可能的话,我该怎么办?
Thanks you in advance and sorry for my bad English. 在此先感谢您,对不起我的英语不好。
请确保您使用的是OGM的最新版本(1.1.4),并且您的图形仅包含一个表示Keanu Reeves的节点(即您没有多次加载电影数据库)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.