Spring Data Rest PUT诉PATCH LinkableResources [英] Spring Data Rest PUT v.s PATCH LinkableResources

查看:91
本文介绍了Spring Data Rest PUT诉PATCH LinkableResources的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Data REST公开我的实体及其关系.我在两个实体之间有一个OneToOne关系,我正在尝试更新/更改与PUT和PATCH的关系.

I'm using Spring Data REST to expose my Entity's and their relationships. I have a OneToOne relationship between two Entity's and I'm trying to update/change the relationship with PUT and PATCH.

我注意到Spring Data REST仅允许您通过更新链接资源-Jem映射的实体(OneToMany,ManyToOne等),它们也是AggregateRoots(具有存储库). PATCH ,并被 PUT 忽略.

I noticed that Spring Data REST will only allow you to update linked resources - JPA mapped Entity's (OneToMany, ManyToOne, etc) which are also AggregateRoots (has a Repository) - via a PATCH and are ignored with a PUT.

这可以在这是为什么?背后的原因是什么?

Why is this? What is the reasoning behind this?

是因为设计希望我们将关联视为资源本身,如

Is it because the design wants us to treat the associations as resources themselves as seen in this part of the documentation? I can alter the relationship via a PUT with Content-Type text/uri-list but it feels unnatural and require an additional HTTP request.

推荐答案

从Spring数据REST 2.5.9.RELEASE起,关联不会根据PUT请求进行更新,而仅使用PATCH进行更新.

From the Spring data REST 2.5.9.RELEASE the associations are not update on PUT request and only update using PATCH.

版本2.5.9.RELEASE中的更改(2017-04-19)

Changes in version 2.5.9.RELEASE (2017-04-19)

DATAREST-1030-无法处理PATCH请求正确链接到关联.

与此有关的其他链接:

DATAREST-1061:具有应用程序/json媒体类型有效负载的PUT请求无法更新关联@OneToOne通过URI

域驱动设计和弹簧

这篇关于Spring Data Rest PUT诉PATCH LinkableResources的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆