4

I am using Spring Data REST using a CRUD repository, some values should be optionally NULL, however if I try to set them to null, the fields in question get ignored. If I send non-NULL data it works as expected

Is there are a way to allow this functionality?

Here is a sample PUT request body

{
 "name": "Ash Test",
 "distance": null,
 "paid": null,
 "startDate": null,
 "tags": [  ],
 "position": 3,
 "creator": true,
 "memberId": 55
}
francisco
  • 1,387
  • 2
  • 12
  • 23
Ash McConnell
  • 1,340
  • 1
  • 17
  • 28
  • are you using jackson? – harsh Apr 19 '13 at 13:12
  • 1
    related: http://stackoverflow.com/questions/12707165/spring-rest-service-how-to-configure-to-remove-null-objects-in-json-response – harsh Apr 19 '13 at 13:14
  • Thanks for your answer, I am using jackson. That other question relates to the response I believe, I am concerned with updating an existing record with PUT. – Ash McConnell Apr 19 '13 at 13:55
  • Can you update with the values that you receieve? You really need to get the null values? – Deividi Cavarzan Apr 19 '13 at 18:49
  • Hi Deividi, I am trying to do an update on the db(using PUT). As some background the data above represents a filter, if the value of paid in the db is true the filter will pull out records with paid = true, but if it's null the filter will ignore whether it's paid or not. This is why I want to be able to update the value in the DB to null. When I use the data above to do an update the paid field should be null, but it remains at it's previous value. – Ash McConnell Apr 20 '13 at 16:11

1 Answers1

0

This appears to be a known issue at the time of this writing:

https://jira.springsource.org/browse/DATAREST-130

It affects both SDR 1.0.0.RELEASE and SDR 1.1.0.M1. I just tried it with 2.0.0.BUILD-SNAPSHOT and the nulls don't currently go through there either.