Skip to content

WIP Cascade entities loaded during flush #2103

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Apr 5, 2019

This change allows to properly flush and cascade entities that were loaded and modified during flush (I know this is not recommended way of doing things but sometime it can be useful)

Fixes #1252

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

This is extremely weird use case. I spent too much time trying to understand what's going on.

@bahusoid
Copy link
Member Author

Yeah. I agree test case from #1252 is very weird. But in general this PR covers condition when entity is modified on loading event and this loading happens during flush for whatever reasons (non lazy association or something like that)

In test case it's not even loading it's proxy creation.

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

This is what it takes to make the test green (90ea467):

public Child()
{
if ( CREATE_WITH_TOY )
DynamicToy = new Toy();
}

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

The culprit is access="readonly". This so called "feature" should have never been implemented.

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

The test becomes green when either:

  • DynamicToy is set using the property
  • DynamicToy does not have access="readonly"

@bahusoid
Copy link
Member Author

The test becomes green when either:
DynamicToy is set using the property

That's because of stupid logic inside property setter. Yeah test is strange and I should have come up with something more simpler and clear instead of reusing it. But again the issue should be clear: entity is loaded and modified during flush. Cascade changes won't be applied for such entities. If you have some complex checks in interceptor - it's quite possible scenario (I've personally investigated it in some legacy app).

I will try to add some simple test demonstrating this behavior as I agree current test is hard to understand

@bahusoid
Copy link
Member Author

Actually I can't come up with anything that looks sane :) Maybe such scenarios are indeed should be considered too specific to be handled in nhibernate. So feel free to close this PR...

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

DynamicToy does not have access="readonly"

This still holds.

@hazzik
Copy link
Member

hazzik commented Jun 17, 2019

These tests need a sensible asserts at least. They currently do not check anything (except implicit check for TransientObjectException).

@bahusoid bahusoid changed the title Cascade entities loaded during flush WIP Cascade entities loaded during flush Mar 31, 2020
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.

NH-2919 - Cascade update doesn't work for lazy loaded entities that are loaded by the flush
2 participants