Skip to content
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

breaking: fix serialization issues in BaseService#update and use JsonPatch for updatePartial #608

Merged
merged 7 commits into from
Nov 21, 2022

Conversation

LukasLohoff
Copy link
Member

@LukasLohoff LukasLohoff commented Nov 17, 2022

Description

Fixes issues with properties being overridden by removing the serialization in BaseService#update.

Extracted from #515:

Herein the update method is updated to not serialize the update candidate anymore. In addition the updatePartial has been reworked to make use of JSON Patch and the @DynamicUpdate annotation is presented for all entities.

❗ Breaking change - Migration notes: ❗

1. BaseService#updatePartial changed its method signature.

Old:

public S updatePartial(Long entityId, S entity, Map<String, Object> values)

New:

public S updatePartial(S entity, JsonMergePatch patch)

Projects which override updatePartial or use it directly need to update their code accordingly.

2. BaseController#updatePartial changed its signature

Projects using the endpoint PATCH /{entityClass}/{id} should update their client code:

  • supplying the entity id in the json body is no longer necessary

3. Annotate your hibernate models with @DynamicUpdate

For more information see https://www.baeldung.com/spring-rest-json-patch#http-patch-request

Related issues or pull requests

Pull request type

  • Bugfix
  • Feature
  • Dependency updates
  • Tests
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe)

Do you introduce a breaking change?

  • Yes
  • [] No

Checklist

  • I understand and agree that the changes in this PR will be licensed under the
    Apache Licence Version 2.0.
  • I have followed the guidelines for contributing.
  • The proposed change fits to the content of the code of conduct.
  • I have added or updated tests and documentation, and the test suite passes (run mvn test locally).
  • I have added a screenshot/screencast to illustrate the visual output of my update.

@LukasLohoff LukasLohoff marked this pull request as ready for review November 18, 2022 08:04
@LukasLohoff
Copy link
Member Author

@terrestris/devs Please review

@LukasLohoff LukasLohoff changed the title fix serialization issues in BaseService#update breaking: fix serialization issues in BaseService#update and use JsonPatch for updatePartial Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BaseService.update returns object that is not a hibernate proxy
2 participants