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
Support for non-updatable fields [DATAREST-530] #905
Comments
Oliver Drotbohm commented Actually, that's the way What we could do though is inspecting certain annotations and consider the fact that they basically are read-only properties in the JSON Schema that we expose. Spring Data Commons already has an My hesitance aside, what kind of error (HTTP status code) were you imagining, actually? |
Dave LeBlanc commented Well, speaking for myself I'm ok with it simply not persisting changes to the entity. The group I'm working with was expecting an error message to be thrown when trying to update a read-only field -- probably with a 403 Forbidden status code. Alternatively, if there was a reasonable way to hook in to SDR to provide such a mechanism ourselves (so it's not the default, but still possible) this might be interesting |
Ben Madore commented I, for one, would love a mechanism to expose somethign as readOnly in the json schema. - seems like to ensure it's a match with serialization, instead of using hte JPA annotation, you could use the upcoming jackson ```
|
Ben Madore commented Also - for read only properties, it'd be great to not only expose that they're 'readOnly' but also to expose the schema for the non-entity object. In general it would be nice to expose a mechanism to provide the schema for non-entity objects as that's a fairly common use case where you might need to return a computed value on your API (e.g. I have a ```
DailyHours getTodaysHours()
|
Oliver Drotbohm commented As mentioned above |
Adam Rosini commented My issue is that when I PATCH an update, the returned response body looks like the read-only fields were updated. After inspecting the database, they are not because they are excluded from SQL via the Having an error be thrown would be fine for my use case and I think actually makes sense, I see it as a 400 or 403. So +1 for this |
Massimiliano Bigatti commented I'm experiencing the same issue described by Adam: with a PATCH request the response body contains the updated value for the field annotated as |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Dave LeBlanc opened DATAREST-530 and commented
Currently with spring-data-jpa and SDR, when we submit an update to an entity that has a non-updatable property (
@Column
(updatable=false)) we don't get an error message when we try to edit that property - the update won't happen, but we don't get any error notification.If there's an reasonable way to implement this, my preference would be for an update attempt to that field to throw an error
Issue Links:
DATAREST-531 JSON Schema should expose read-only fields based on PersistentProperty.isWritable()
DATAJPA-716 JpaPersistentProperty should consider updatable flag of mapping annotations
Referenced from: commits 70a2488, f05a6ba
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: