GithubHelp home page GithubHelp logo

Comments (17)

meistermeier avatar meistermeier commented on May 20, 2024

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 Movie OGM / SDN do not get any information about the Person. I did not test it myself, but it should work if you additionally returncollect(p).

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

You mean collect(m)? Where is the p?

from movies-java-spring-data-neo4j.

meistermeier avatar meistermeier commented on May 20, 2024

Oh, sorry, no I meant collect(a).

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

collect(a) just gives more movies, but the actors[] are still all empty.

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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.

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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.

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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.

from movies-java-spring-data-neo4j.

meistermeier avatar meistermeier commented on May 20, 2024

It seems that (at least) a word is wrong here:

If you change the List to List in the Movie class

But I could reproduce the problem and you have to collect both relationship related "values". @Query("MATCH (m:Movie)<-[r:ACTED_IN]-(a:Person) RETURN m, collect(r), collect(a) LIMIT {limit}") works.

(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

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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".

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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.

from movies-java-spring-data-neo4j.

meistermeier avatar meistermeier commented on May 20, 2024

Got it. Finally. Because you have the Role class in you class path OGM finds this class and put all the information into this relationship and skips evaluating the @Relationship annotations in the @NodeEntity classes because it has already found a matching relationship representation. After assembling the objects it "sets" the Role in Movie but unfortunately there is no field matching this type, so it does not get set.
So, your solution would be to remove the Role class, remove the @RelationshipEntity annotation or at least change the name of the relationship type in the annotation.

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

@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?

from movies-java-spring-data-neo4j.

meistermeier avatar meistermeier commented on May 20, 2024

The JSON does only get generated from the field names. So the only way is to add the annotation @JsonProperty("acted_in") or rename the field (and may be getters).

from movies-java-spring-data-neo4j.

lingvisa avatar lingvisa commented on May 20, 2024

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.

from movies-java-spring-data-neo4j.

meistermeier avatar meistermeier commented on May 20, 2024

If it is just for the representation, you should add this annotation to your actors property in the Movie class.

from movies-java-spring-data-neo4j.

manavilai avatar manavilai commented on May 20, 2024

@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

from movies-java-spring-data-neo4j.

michael-simons avatar michael-simons commented on May 20, 2024

Closing this as question. Feel free to discuss this on our community site.

from movies-java-spring-data-neo4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.