Skip to content

Ability to save entities without triggering events#5343

Open
knstvk wants to merge 1 commit into
masterfrom
5116-save-entites-without-events
Open

Ability to save entities without triggering events#5343
knstvk wants to merge 1 commit into
masterfrom
5116-save-entites-without-events

Conversation

@knstvk
Copy link
Copy Markdown
Contributor

@knstvk knstvk commented Jun 2, 2026

Adds two SaveContext hints that let callers suppress lifecycle events when saving via DataManager, for use cases like bulk import and technical/system updates that shouldn't trigger business logic.

New hints (io.jmix.data.PersistenceHints):

  • SKIP_ENTITY_SAVING_EVENT — suppresses EntitySavingEvent
  • SKIP_ENTITY_CHANGED_EVENT — suppresses EntityChangedEvent

The two are independent; default behavior (hints absent) is unchanged.

dataManager.save(new SaveContext()
        .saving(entity)
        .setHint(PersistenceHints.SKIP_ENTITY_CHANGED_EVENT, true)
        .setHint(PersistenceHints.SKIP_ENTITY_SAVING_EVENT, true));

Implementation: JpaDataStore.saveAll() skips EntitySavingEvent publishing; beforeSaveTransactionCommit() skips EntityChangedEvent publishing while still running change collection and entity detachment.

Caveats (documented on the constants): suppressing EntitySavingEvent also skips multitenancy tenant-id assignment; suppressing EntityChangedEvent also skips full-text search re-indexing and security cache invalidation. Audit fields (JPA descriptor level) and the audit entity log (JpaLifecycleListener) are not affected.

@knstvk knstvk linked an issue Jun 2, 2026 that may be closed by this pull request
@knstvk knstvk requested a review from Gavrilov-Ivan June 2, 2026 08:50
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.

Ability to save entities without triggering events

1 participant