0

This is a spring-boot application and I've got couple of @Entitys and their respective @RepositoryRestResources. App is parent and History is child in the DB. When I'm trying to add new record to History (using POST), I can't figure out why version and tag are null in the response.

These fields are null in DB too. Debugging realized the request is not deserialized properly. Anyone seen this issue before?

Suspecting this fix to be the cause, can't really confirm because downgrading the jackson version didn't help. Full application is here.

$ curl -d '{"app":{"appId":1,"name":"test2"},"version":"v13","tag:"tagtest1"}' -H "Content-Type: application/json" -X POST http://localhost:8080/repo/history

Response :

{
  "version" : null,
  "tag" : null,
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/repo/history/1"
    },
    "history" : {
      "href" : "http://localhost:8080/repo/history/1"
    },
    "app" : {
      "href" : "http://localhost:8080/repo/history/1/app"
    }
  }
}
Anand Rockzz
  • 6,072
  • 5
  • 64
  • 71

1 Answers1

0

I cloned your repository, and it's working but a couple of things, I'm not sure how you can send directly ManyToOne Object because that is the mistake in order to map it. because if you send the below body, it will be mapped version and tag but the app JSON object no, so you have to research about how to pass a JSON Object with realtionship Many to one. You need to take a look this answer Save child objects automatically using JPA Hibernate

{
    "version":"v13",
    "tag":"tagtest1",
    "app":{
        "appId": 1, 
        "name":"test112"
    }
}
Jonathan JOhx
  • 5,784
  • 2
  • 17
  • 33