-
Notifications
You must be signed in to change notification settings - Fork 934
Fix cascade + one-to-one failing on null no-proxy association #1720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cascade + one-to-one failing on null no-proxy association #1720
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to let you know why an upcoming commit is going to alter the test.
/// if you prefer. | ||
/// </remarks> | ||
[TestFixture] | ||
public class ByCodeFixture : TestCaseMappingByCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to test for both mappings style, better remove one of them.
namespace NHibernate.Test.NHSpecificTest.GH1719 | ||
{ | ||
[TestFixture] | ||
public class Fixture : BugTestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async generator will generate an async counterpart for this test. Not generating it would cause some later generation to add it in an unrelated change, so it has to be generated. (Option H
of showbuildmenu.bat
, see contributing.)
I have pushed a minimal fix, see commit details. |
Something causes the test to fail for Oracle, going to check locally. (Update: a string column is set as not null but an entity attempt so set it with the empty string, which is handled as null by Oracle. So I am putting something in that string, this string being empty is irrelevant to the test.) And well, rebasing for squashing things in two commits: the test then the fix.
I think the Hibernate change is also notably aiming at reducing the lazy loads triggered by cascades. Some are mandatory, by example when cascading a delete, other should be avoidable, by example when searching for orphans in order to handle delete-orphan. |
This is a lightweight fix which does not change the no-proxy principles at the root of the bug. The no-proxy is currently implemented as a special case in the lazy property interceptor, not flagged as a lazy property. Instead, on parent entity load, it hides, in the parent loaded state for the no-proxy, a proxy (!) flagged for unwrapping the associated entity it proxifies. This hiden unwrapping proxy supports proxifying non-existent entities. The property interceptor does the unwrapping when accessing it. But when the proxy unwraps to null, this causes the loaded state to have a reference where it should be indeed null, causing dirty checking issues. A better fix would be to flag the property as lazy for no-proxy one-to-one associations, allowing to get in the loadedState the "uninitializedProperty" instance, allowing the dirty checking mechanism to know that this part of state is unknown (till loading it, at which point it should be adjusted to its actual value). But this causes the property interceptor to trigger initialization of any other lazy properties when accessing a one-to-one. Avoiding this would require to implement some lazy property fetch group semantic. Fixes #1719 Co-authored-by: Alexander Zaytsev <hazzik@gmail.com>
A unit test failure is expected, demonstrating #1719.