Frachtwerk / essencium-backend

Essencium Backend is a software library built on top of Spring Boot that allows developers to quickly get started on new software projects. Essencium provides, for example, a fully implemented role-rights concept as well as various field-tested solutions for access management and authentication.
GNU Lesser General Public License v3.0
15 stars 3 forks source link

Patch preprocessing implementation not useful #105

Open pwannenmacher opened 1 year ago

pwannenmacher commented 1 year ago

Suggestion for improvement

The current implementation of PATCH iterates over all map entries and sets their value on the target object (database object, NOT DTO), e.g. User. For primitive types this is ok. But for complex objects it is not.

Example: I want to set an image of type UploadedFile for my AppUser (subclass of User), which I reference by its id (Long). If I now send PATCH /v1/users/25 with { "image": 324 }, it would try to place a Long in the place of an UploadedFile via reflection.

Either this functionality should be fundamentally rebuilt or consider applying the patches from the Map Entries to the associated DTO rather than the Model. A "workaround" is to override the patchPreProcessing() method in the corresponding concrete server and replace the primitive Map Values with complex objects.

Use-Case

Implementation proposals

Additional Information

hoelger-frachtwerk commented 6 months ago

my notes from discussion with paul

double check if also required for AbstractUserController