Spring Data REST - PUT request does not work properly since v.2.5.7

浪子不回头ぞ 提交于 2019-11-29 03:47:27

Looks like the issue has already been reported as a bug: - please verify. As best as I can tell, this is the issue you are reporting above.

Note, I am revising my previous answer to be this bug report.

I agree with you that this is a bug in Spring Data REST and it should be reported.

I have the same issue in my project, where updating an entity via PATCH request works fine, but PUT request updates only fields of the given entity, but not its associated resources.

Why do I consider this a bug?

  • As people have correctly pointed out, PUT should be used for replacing a resource as a whole with a modified version, which suggests that it should be working, if you provide all fields for the resource (as in a POST request). However, in current Spring Data REST version, only the simple fields of an entity are updated and the associated resources are left intact which makes PUT request only "partially working" and that is definately not an expected behavior (even if it fulfills the RFC).
  • Moreover, Spring Data REST even allows you to do a partial PUT request, i.e. updating just your name field via PUT works. It does not work for the address though.
  • It means that Spring Data REST does not work exactly how the RFC specifies it (which may be for another debate), however it also does not provide a consistent usage - when updating one field works and updating other does not without any sign of an error.

For the record, I am using Spring Data REST 2.6.3.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!