Comments (17)
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.
You mean collect(m)? Where is the p?
from movies-java-spring-data-neo4j.
Oh, sorry, no I meant collect(a)
.
from movies-java-spring-data-neo4j.
collect(a) just gives more movies, but the actors[] are still all empty.
from movies-java-spring-data-neo4j.
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.
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.
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.
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.
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.
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.
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.
@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.
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.
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.
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.
@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.
Closing this as question. Feel free to discuss this on our community site.
from movies-java-spring-data-neo4j.
Related Issues (20)
- How do you update only some properties from a node? Where are the rest of the CRUD examples?
- Uncaught TypeError: Cannot read property 'person' of undefined at (index):93 HOT 4
- Populate neo4j set value. HOT 1
- Does the project work with neo4j online? HOT 1
- How to POST ? HOT 1
- Boot run doesnt work along with failed tests HOT 1
- After setting the value of id, neo4j cannot successfully create a node. HOT 1
- why so many (type = "ACTED_IN") in code ? HOT 1
- AuthenticationException with an application.yml config file HOT 1
- Why is the result different between junit test and http request
- Quesioned with RelationshipEntity annotation HOT 3
- what is the 4th sentence really means in ReadMe Quickstart? HOT 1
- Link on Neo4j Developer Site dead HOT 1
- Create new node HOT 1
- How to append costum @Query string? HOT 1
- sessionFactory issue HOT 1
- Dependency not found in Maven repo HOT 3
- how could I create dynamic relationship by using sdn6 HOT 2
- Investigate CI failure
- How to save the relationship separately HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from movies-java-spring-data-neo4j.