Skip to content

Conversation

@Aftermoon-dev
Copy link
Contributor

@Aftermoon-dev Aftermoon-dev commented Oct 11, 2025

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

In internal/entities/mapper/relation/ToOneEntityLoader.java -> loadImmediate method checks @NotAudited through enversService.getEntitiesConfigurations().getNotVersionEntityConfiguration( entityName ) == null, but if set @Audited (targetAuditMode = RelationshipTargetAuditMode.NOT_AUDITED) in FK, it seems that the reason is that it is not checked.

I updated loadImmediate Method to check that part.


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.


@Aftermoon-dev Aftermoon-dev marked this pull request as draft October 12, 2025 08:28
@Aftermoon-dev Aftermoon-dev marked this pull request as ready for review October 12, 2025 08:49
@Aftermoon-dev
Copy link
Contributor Author

Aftermoon-dev commented Oct 12, 2025

I also added tests to check that the RelationTargetAuditNotfoundAction options (IGNORE, ERROR) work properly when applying the change.

@Aftermoon-dev
Copy link
Contributor Author

Aftermoon-dev commented Dec 25, 2025

I migrated my test code to JUnit 5 😄

Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

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

Thanks @Aftermoon-dev, left a couple comments but the overall idea looks fine. It's weird that this target audit mode is completely ignored apart from a single place in the code where we perform a check on the mapping's consistency.

@Aftermoon-dev Aftermoon-dev force-pushed the HHH-19861 branch 2 times, most recently from 5137727 to 2ebae6a Compare January 9, 2026 14:57
@Aftermoon-dev Aftermoon-dev requested a review from mbellade January 9, 2026 15:02
@Aftermoon-dev Aftermoon-dev changed the title HHH-19861 Fix EntityNotFoundException when using @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) on FK fields HHH-19861 Fix EntityNotFoundException when using targetAuditMode NOT_AUDITED on FK fields Jan 10, 2026
Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

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

Almost good @Aftermoon-dev, also please squash everything to 1-2 commits.

@Aftermoon-dev Aftermoon-dev force-pushed the HHH-19861 branch 2 times, most recently from 24a7525 to f386db9 Compare January 12, 2026 14:37
@Aftermoon-dev
Copy link
Contributor Author

Almost good @Aftermoon-dev, also please squash everything to 1-2 commits.

@mbellade Thank you for your review! I updated it and squash to 1 commit 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants