Skip to content

Fix #2608 - persisting a one-to-one with delayed insert fails #2609

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

Merged
merged 8 commits into from
Jan 26, 2021

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Nov 22, 2020

Fix #2608.

@fredericDelaporte fredericDelaporte added this to the 5.3.6 milestone Nov 22, 2020
Comment on lines -35 to +37
<generator class="increment"/>
<generator class="foreign">
<param name="property">Person</param>
</generator>
Copy link
Member Author

Choose a reason for hiding this comment

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

We already had a test really near what is required for reproducing #2608, unfortunately ignored and anyway, not using an id strategy on its parent which would be adequate for triggering the bug. As switching the parent id strategy would impact other tests, I have just fix that other test.
Strictly speaking it should go in a dedicated PR, but let it be here.

{
var p = new Person { Name = "steve" };
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p };
s.Merge(p);
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the same exception should be thrown on Persist too. Am I right?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, persist does not fail, it least with my tests on a modified MergeFixture.

Copy link
Member

Choose a reason for hiding this comment

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

Strange... I thought it's directly related to #1754 in which case Persist should fail the same (at least for this test case). I added test for Persist - let's see...

Copy link
Member

@bahusoid bahusoid Nov 25, 2020

Choose a reason for hiding this comment

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

And Persist fails the same...

it least with my tests on a modified MergeFixture.

But in current state it also doesn't fail on Merge.... The only failed tests are newly added GH2608

Copy link
Member Author

Choose a reason for hiding this comment

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

The MergeFixture one fails if we change its id generator from increment to identity. But as this would mean changing from a app-side generated id to a db-side one, I have not done that change, it would change too much the test.

I have re-checked these GH2608 tests on 5.2.x just in case, both succeed on 5.2.x.

@fredericDelaporte
Copy link
Member Author

About working on a fix, it will be maybe on next week-end, if not done by someone else before that.

@bahusoid
Copy link
Member

So it's regression after #1754. Reason: Delayed foreign id is not supported (exception is thrown when DelayedPostInsertIdentifier is tried to be set for entity with foreign id generator). Doesn't look easy fixable (if we want to keep delayed insertion)

@fredericDelaporte fredericDelaporte changed the title WIP - Test for #2608 Fix #2608 - persisting a ono-to-one with delayed insert fails Dec 26, 2020
@fredericDelaporte fredericDelaporte changed the base branch from master to 5.3.x December 27, 2020 15:35
@fredericDelaporte
Copy link
Member Author

The fix is not hard after all, while keeping things delayed.
I have rebased this on 5.3.x, it was on master.

@fredericDelaporte fredericDelaporte changed the title Fix #2608 - persisting a ono-to-one with delayed insert fails Fix #2608 - persisting a one-to-one with delayed insert fails Jan 10, 2021
@fredericDelaporte fredericDelaporte merged commit 39a28aa into nhibernate:5.3.x Jan 26, 2021
@fredericDelaporte fredericDelaporte deleted the GH2608 branch January 30, 2021 17:43
bahusoid added a commit to bahusoid/nhibernate-core that referenced this pull request Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delay entity insert may fail with Merge
3 participants