-
Notifications
You must be signed in to change notification settings - Fork 565
Backend read-only properties overridden for PATCH requests [DATAREST-1383] #1743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oliver Drotbohm commented This shouldn't actually happen and clearly needs investigating. However, you should be able to see this handled better is by using Jackson annotations and properly mark the property as read only. Without that in place, Jackson will bind the incoming data to the object's field as it doesn't know about JPA specific semantics. I'll still have to investigate why JPA is not properly rejecting to persist the field. Can you clarify whether what you see is just the immediate response? Or has the data been changed persitedly? I.e. if you issue another GET request on the item resource, do you see the old or the new data. I am asking because here's what I think happens:
|
Oliver Drotbohm commented What still puzzles me is that Jackson apparently changes a |
XhstormR commented I can confirm that the data in the database has not changed after sending the patch request. After sending the patch request, there is no update statement in the hibernate log. The Get request after the patch request returns the correct read-only attribute value. It seems that the value of the read-only property is changed only in the View layer |
XhstormR commented The PUT request will recognize the read-only attribute, but the PATCH request will not recognize the read-only attribute. I think it may be that some operations are missing from processing the PATCH request |
Oliver Drotbohm commented In fact, it's the other way round: for PATCH, we rely on Jackson's |
Oliver Drotbohm commented That's fixed. Feel free to give the latest snapshots a try |
Oliver Drotbohm commented We unfortunately need to revisit the fix for this here in the course of fixing DATAREST-1524. I looks like inspecting the persistence configuration regarding updatability is the wrong place to start with as that can be at odds with what's expected to happen at the JSON binding level. For the latter, there actually is e.g. |
XhstormR opened DATAREST-1383 and commented
I have an Person entity like this:
Its name attribute is specified as not updatable.
I use the curl command to create a Person entity:
When I modify the entity property using the http put method, the read-only property returns the correct value, the value of the name attribute is Dave:
But when I modify the entity property using the http patch method, the read-only property returns the modified value, the value of the name attribute becomes 123:
Issue Links:
@Transient
annotation won't deserialize fields on MongoRepository PATCH requestsBackported to: 3.1.9 (Lovelace SR9)
The text was updated successfully, but these errors were encountered: