Repository navigation
feat(events): carry the previous state on OnObjectUpdate - #52
Open
herbie-bot wants to merge 1 commit into
Open
herbie-bot wants to merge 1 commit into
herbie-bot wants to merge 1 commit into
Conversation
OnObjectUpdate gets a second constructor (previous, current) plus isPreviousKnown() and Optional<T> getPrevious(). The one-argument constructor stays for publishers that cannot know the previous state. The event carries no diff and no actor; listeners compare themselves. AbstractDbBackedDataService and AbstractMultitenantDbBackedDataService snapshot toData(entity) before updateEntity, replace postSave(boolean, D) with postInsert(D) / postUpdate(D, D) and publish no event for an update where previous equals current. GenericDataEvent now implements ResolvableTypeProvider: typed listeners such as OnObjectUpdate<BookDto> previously received events for every DTO type. Spec 022; origin open-tasks#36 (TaskChangedEvent). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ndacyayisenga-droid
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extends the existing
eventsAPI so applications can react to what changed on an update. This is the generic part of open-tasks#36 (TaskSnapshot/TaskChangedEvent). It extendsOnObjectUpdaterather than adding a parallel event type. Spec:docs/specs/022-update-event-previous-state.OnObjectUpdate: new constructor(previous, current)plusisPreviousKnown()andOptional<T> getPrevious(). It rejects apreviousof a different class or with a different id. The one-arg constructor is unchanged, for publishers that cannot know the previous state (e.g. external systems). There is deliberately no diff and no actor in the event.AbstractDbBackedDataService/AbstractMultitenantDbBackedDataService:toData(entity)beforeupdateEntitypostSave(boolean, D)withpostInsert(D)/postUpdate(D previous, D current)previous.equals(current)savecallGenericDataEventimplementsResolvableTypeProvider. Before this, a typed listener such as@EventListener OnObjectUpdate<BookDto>was invoked for every DTO type. A probe test confirmed that, and the newTypedEventListenerTestcovers it.Breaking / behaviour changes (documented in
upgrade-to-1.5.md)postSave(boolean, D)no longer compiles. This is intentional: a silent change would be worse.toDatamust return a snapshot. A DTO that shares an entity collection would swallow update events. AlltoDataimplementations in this repository comply.Tests
New and extended unit tests for the event constructors, the resolvable type, typed dispatch in a real Spring context, and update / no-op behaviour in both data service base classes. A full
mvn verifypasses locally, including the Testcontainers integration tests.🤖 Generated with Claude Code