-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why doesn't this work after my minor modification the movie class? #25
Comments
If you are using a custom query, there is no default depth of 1 used for the querying. It is the "plain" result of your query. Because you just return the |
You mean collect(m)? Where is the p? |
Oh, sorry, no I meant |
collect(a) just gives more movies, but the actors[] are still all empty. |
Maybe because the Role has properties, I must use the RelatinoshipEntity? I just want to test something simpler. And I created another little graph for another domain without relationship property, but it ended up with the same thing. So I guess I am missing something. Maybe needs some setting somewhere. |
I tested this "@query("MATCH (m:Movie)<-[r:ACTED_IN]-(a:Person) RETURN m, r, collect(a) LIMIT {limit}")". The actors:[] are empty as well. |
Hi, meistermeier: Do you have a chance to take a look at this? If you change the List to List in the Movie class, then use @query("MATCH (m:Movie)<-[r:ACTED_IN]-(a:Person) RETURN m, r, collect(a) LIMIT {limit}"), you will see the result. Thanks a lot. |
It seems that (at least) a word is wrong here:
But I could reproduce the problem and you have to collect both relationship related "values". (edit) I added a sample to my sdn playground project https://github.com/meistermeier/sdn-showcase/blob/d4f7b807735cae2239c5789bbbd1954805ffc5d9/src/test/java/com/meistermeier/neo4jsdn/sdnshowcase/CustomQueryTest.java |
Hi, meistermeier: I put my version of the movie onto: https://github.com/lingvisa/test-movie.git and could you clone and have a test at why it still doesn't work? I followed your suggestion but still got empty results for the persons[]. The only change I made is to change to List in Movie, and then in the service/repository class I changed the return value to Collection movieRepository.graph(limit), since I don't want to see the original visualization, but only want to the see json output in Browser. I looked at your customquerytest example too. The query I used for testing is "http://localhost:8080/graph?limit=10". |
I tested in both the Movie project and the sdnshowcase project, in the unit test, the "collect(r), collect(a)" doesn't matter, whether collect is used, since the test is only relevant to the Movie or Person object, the first returned value. The unit test doesn't reveal anything about the issue when requesting through the restful service, the Collection is empty. |
Got it. Finally. Because you have the |
@meistermeier I updated my question above with my current json output. The output is almost what I want to see, except that it doesn't output the relationship "ACTED_IN". In json, I need to know what the relationship between Movie and Person. How to get that output too? |
The JSON does only get generated from the field names. So the only way is to add the annotation |
Do you mean I need to define a new variable like "relation" in Movie and set the @JsonProperty annotation? If I add a new variable, the Movie's constructor has to be changed too. I guess I am not getting your point. In addition, most likely I also need to output the direction (Incoming/outcoming) together with the relationship name. I am thinking defining a new class to contain the relationship name and direction and then define this as an instance variable of the model class. But it seems awkward. What's the usual practice? I simply want the JSON object returned by the query contains the triples: Subject, Relation and Object. In this case, they are Movie, Acted_IN (incoming), and Persons. |
If it is just for the representation, you should add this annotation to your |
@lingvisa , did you get a chance to fix this..i have a similar issue when i query by personrepo.findByName(). It doesn't return the movies |
Closing this as question. Feel free to discuss this on our community site. |
If in the Movie class, I only keep a list of Persons without the Role list, and in the Person class, there is a list of Movie.
Person class:
Movie class:
MovieRepository:
Why the "actors" is empty when I query the Movie repository? I have the following json output:
I am using the query: "MATCH (m:Movie)<-[r:ACTED_IN]-(a:Person) RETURN m, r, collect(a) LIMIT {limit}". How to output the relationship "ACTED_IN" in the json output? since that would be required in application. The output above only have Movie and the Persons associated with it.
The text was updated successfully, but these errors were encountered: