kandi X-RAY | sdn-university Summary
kandi X-RAY | sdn-university Summary
sdn-university
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sdn-university
sdn-university Key Features
sdn-university Examples and Code Snippets
Community Discussions
Trending Discussions on sdn-university
QUESTION
In an attempt to recreate the Spring Data Neo4j official Movies example in Scala I have ran into an issue jsonifying on the Spring Data Neo4j layer.
The details are noted in the README
in this example project.
Booting the Spring app and hitting /movies/
gives the following stacktrace:
018-03-27 15:33:23 WARN DefaultHandlerExceptionResolver:442 - Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Invalid Object Id definition for movies.Movie: cannot find property with name 'id'; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid Object Id definition for movies.Movie: cannot find property with name 'id' (through reference chain: org.springframework.hateoas.PagedResources["_embedded"]->java.util.Collections$UnmodifiableMap["movies"]->java.util.ArrayList[0])
I have opened an official Spring Data Neo4j JIRA issue here.
Edit: After the latest comment, I have removed unrelated theories about the root cause from this post. And I have updated the example project to expose the IDs on the Spring Data Rest
layer using a PostConstruct
method (thanks @meistermeier). I also tried the RepositoryRestConfigurerAdapter
method. However, the original HttpMessageNotWritableException
persists. Any ideas?
Update:
Modeling Movie.scala
after SDN-University example, I tried using com.voodoodyne.jackson.jsog.JSOGGenerator
as an Object ID Generator. I can successfully hit /movies/
but the only key is "id", and it's simply an index, and not the actual id. However, 38 movies do return, the amount in the Movies data set. I would think this narrows down the issue to the jsonfying part.
Update 2:
By using a bandaid to manually form the json
in the controller (using an object-to-map
function, and a map-to-json
function) I am finally able to send data out through the endpoints. I have updated the example project to demonstrate this. I can successfully retrieve objects from the movieRepository
, and manipulate them as I please. I think this has clearly narrowed down the problem to the jsonification. Does anyone have a clear example (Java or Scala) on how to properly annotate NodeEntity
with JsonIdentifyInfo
?
ANSWER
Answered 2018-Mar-30 at 08:16First a note on the id as String
part: The internal Neo4j id has to be of type Long
(paragraph between the info sections here: https://neo4j.com/docs/ogm-manual/current/reference/#reference:annotating-entities:entity-identifier). With another type than Long
Neo4j OGM is unable to find the, so called, native id field on your class.
Now back to the initial problem you are facing.
Spring Data Rest suppresses the exposure of id-like fields and Spring Data Neo4j will mark/register fields with an @Id
annotation as such.
To use this id fields you could for example do something like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sdn-university
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page