Spring Data Rest PUT vs PATCH LinkableResources

I use Spring Data REST to expose my Entity and their relationship. I have one OneToOne relationship between two Entity, and I'm trying to update / change the relationship with PUT and PATCH.

I noticed that Spring Data REST will allow you to update related resources - JPA matched Entity (OneToMany, ManyToOne, etc.), which are also AggregateRoots (has a repository) - through PATCH and are ignored using PUT .

This can be seen in the LinkedAssociationSkippingAssociationHandler class:

if (associationLinks.isLinkableAssociation(association)) {
  return;
}

Why is this? What are the reasons for this?

Is it because design wants us to consider associations as resources themselves, as shown in this part of the documentation ? I can change the relationship via PUT with the text Content-Type / uri-list, but it looks unnatural and requires an additional HTTP request.

+4
source share
1 answer

From Spring REST 2.5.9.RELEASE data, associations are not updated by the PUT request and are updated only using PATH.

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

DATAREST-1030 - PATCH requests do not handle association references properly.

Other links:

DATAREST-1061: PUT- application/json @OneToOne URI

Spring

0

Source: https://habr.com/ru/post/1682774/


All Articles