Skip to content

HHH-19971 - Add cascade attribute to @Any and @ManyToAny annotations#12193

Merged
gavinking merged 3 commits intohibernate:mainfrom
awantika1201:HHH-19971
Apr 21, 2026
Merged

HHH-19971 - Add cascade attribute to @Any and @ManyToAny annotations#12193
gavinking merged 3 commits intohibernate:mainfrom
awantika1201:HHH-19971

Conversation

@awantika1201
Copy link
Copy Markdown
Contributor

@awantika1201 awantika1201 commented Apr 16, 2026

https://hibernate.atlassian.net/browse/HHH-19971

@Any and @ManyToAny have no cascade member, forcing users to rely
on the deprecated @cascade annotation to specify cascade behavior for
these association types. This change adds a standard JPA cascade member
to both annotations, consistent with @onetomany, @manytomany, etc.

Changes

  • Added CascadeType[] cascade() default {} to @Any and @ManyToAny
  • Updated AnyBinder and CollectionBinder to pass the new cascade
    values to aggregateCascadeTypes() (previously passed null)
  • Updated javadoc examples on both annotations to use the new member
    instead of @Cascade
  • Added tests for cascade via the new attribute on both @Any and @ManyToAny

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-19971 (New Feature):

  • 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)

Copy link
Copy Markdown
Member

@sebersole sebersole left a comment

Choose a reason for hiding this comment

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

Would be nice to see tests fort other cascade events as well. You already define the associations with CascadeType ALL, so should be pretty straight forward.

Copy link
Copy Markdown
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

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

LGTM.

@gavinking gavinking merged commit 6d1487f into hibernate:main Apr 21, 2026
21 of 23 checks passed
@gavinking
Copy link
Copy Markdown
Member

Thank you, @awantika1201 !

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
60.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

3 participants