Skip to content

Collection flushing and cascading improvements - #13174

Draft
sebersole wants to merge 12 commits into
hibernate:mainfrom
sebersole:collection-flushing
Draft

Collection flushing and cascading improvements#13174
sebersole wants to merge 12 commits into
hibernate:mainfrom
sebersole:collection-flushing

Conversation

@sebersole

@sebersole sebersole commented Aug 10, 2026

Copy link
Copy Markdown
Member

HHH-20765 - Move cascade handling into a dedicated package
HHH-20766 - Improve collection flush handling
HHH-20767 - Improve cascade processing
HHH-20769 - Drop LOCK cascading
HHH-20770 - Drop support for custom CascadeStyle and CascadeAction implementations


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.



Please make sure that the following tasks are completed:
Tasks specific to HHH-20770 (Remove Feature):

  • Add test OR check there is no need for a test
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

Tasks specific to HHH-20769 (Remove Feature):

  • Add test OR check there is no need for a test
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

Tasks specific to HHH-20767 (Improvement):

  • Add tests for feature/improvement
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

Tasks specific to HHH-20766 (Improvement):

  • Add tests for feature/improvement
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

Tasks specific to HHH-20765 (Task):

  • Add test OR check there is no need for a test
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

sebersole added 10 commits July 31, 2026 12:46
Signed-off-by: Steve Ebersole <steve@hibernate.org>
Signed-off-by: Steve Ebersole <steve@hibernate.org>
* Scope traversal state per invocation and improve failure-path diagnostics
* Precompute persister-owned property selections for all built-in cascade actions
* Add comprehensive behavioral, integration, regression, and JMH coverage

Signed-off-by: Steve Ebersole <steve@hibernate.org>
Signed-off-by: Steve Ebersole <steve@hibernate.org>
…plementations

Signed-off-by: Steve Ebersole <steve@hibernate.org>
* Replaced ActionQueue.clearFromFlushNeededCheck(int) with explicit checkpoint/restore semantic.
* Corrected speculative-flush retention, including orphan collection removals.
* Fixed partial-flush collection counts.
* Fixed one-to-many fallback ordinal ranges.
* Prevented NO_OP completion carriers from merging across collection mutations.
* Moved collection diagnostic monitoring from decomposition to physical execution, including explicit/implicit JDBC batches and failure reporting.

Signed-off-by: Steve Ebersole <steve@hibernate.org>
* CollectionMutationId for explicit semantic completion accounting.
* Direct, batched, grouped, zero-operation, failure, and synthesized-fixup handling.
* Improved owner-level @PreUpdate/@postupdate coordination across entity and collection work.
* Statistics deferred until after the coordinated owner @postupdate.
* Removal of the old graph-only callback wrapper/deduplication path.
* Remove-before-recreate interceptor ordering.

Signed-off-by: Steve Ebersole <steve@hibernate.org>
* Replaced the four collection addAction(...) overloads in favor of queue-neutral CollectionMutationInput.
* Shared positive-decision lifecycle preparation.
* Checkpointing, query-space detection, counting, and lowering in both queues.
* Deferred speculative @PreUpdate, including collection mutation or reference replacement.

Signed-off-by: Steve Ebersole <steve@hibernate.org>
* Introduced the concept of CollectionDelta
* Introduced CollectionDeltaProducer owned by CollectionSemantics

Signed-off-by: Steve Ebersole <steve@hibernate.org>

@beikov beikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check if the new implementation does the same logic, but I assume so, given that tests are passing. The code looks reasonable to me, so +1 on integrating.
I would love to get this and eventually also the cascading of key-to-many properties done, so I can continue with my batch generator PR, since the ForeignGenerator triggering this special cascade is a big blocker for me at the moment.

* Introduced CollectionSemantics production of CollectionMutationInterpretation
* Introduced FrozenCollectionRows to avoid multiple inspection of collection state
* Improved coordination of callbacks, cache cleanup, statistics and queued-operation finalization
* (Re)introduced concept of grouped row bindings
* Improved performance of collection flush processing

Signed-off-by: Steve Ebersole <steve@hibernate.org>
@sebersole
sebersole force-pushed the collection-flushing branch from 0edb54b to 36e74a1 Compare August 12, 2026 19:36
* Compact homogeneous collection rows into shared operation templates and row bindings
* Preserve per-row binding, result checking and mutation completion when compaction is not safe
* Avoid repeated collection inspection during graph planning
* Complete collection flush acceptance coverage

Signed-off-by: Steve Ebersole <steve@hibernate.org>
@sebersole
sebersole force-pushed the collection-flushing branch from 36e74a1 to cff9b89 Compare August 12, 2026 22:18
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants