Skip to content

Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the "old" parameter #1499

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 5 commits into from
Dec 30, 2017

Conversation

druidroad
Copy link
Contributor

@druidroad druidroad commented Dec 22, 2017

… identifier passed to the parameter “old”.

The tests EventListener_Entity_ChangeProperty and EventListener_EntityWithCompositeId_ChangeProperty fail for current code in ManyToOneType.IsModified(…) where old parameter is not parsed.

The tests SelectBeforeUpdate_EntityWithCompositeId_ChangeProperty and SelectBeforeUpdate_ManyToOneWithCompositeId_ChangeProperty fail
if we apply Hibernate fix HHH-3730 (var oldIdentifier =GetIdentifier(old, session))

All tests pass if we apply proposed fix: var oldIdentifier = IsIdentifier(old, session) ? old : GetIdentifier(old, session);

I added extra tests to see what data hit the ManyToOneType.IsModified(…). We can leave just 4 tests listed above and remove or set to [Ignore] others.

ManyToOneType.IsModifiedAsync(...) could be fixed same way but would like to hear the feedback on the issue and proposed solution first.

Fixes #1496.

…stance and identifier passed to the parameter “old”.

The tests "EventListener_Entity_ChangeProperty" and "EventListener_EntityWithCompositeId_ChangeProperty" fail for current code in ManyToOneType.IsModified(…) where "old" parameter is not parsed.

The tests "SelectBeforeUpdate_EntityWithCompositeId_ChangeProperty" and "SelectBeforeUpdate_ManyToOneWithCompositeId_ChangeProperty" fail
 if we apply Hibernate fix HHH-3730 "(var oldIdentifier =GetIdentifier(old, session))"

All tests pass if we apply proposed fix: "var oldIdentifier = IsIdentifier(old, session) ? old : GetIdentifier(old, session);"

I added extra tests to see what data hit the ManyToOneType.IsModified(…). We can leave just 4 tests listed above and remove or set to [Ignore] others.

ManyToOneType.IsModifiedAsync(...) could be fixed same way but would like to hear the feedback on the issue and proposed solution first.
@fredericDelaporte
Copy link
Member

ManyToOneType.IsModifiedAsync(...) could be fixed same way but would like to hear the feedback on the issue and proposed solution first.

No need to wait, async code is generated: just regenerate it. (Do not manually edit it.) Follow contributing instructions. Async generation is an option of the build menu.

Misha Urubkov added 2 commits December 22, 2017 09:17
@druidroad
Copy link
Contributor Author

druidroad commented Dec 22, 2017

DONE. Generated Async method with tests. See 98b1918 commit.

@fredericDelaporte fredericDelaporte self-requested a review December 23, 2017 23:50
Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

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

Looks good overall. Needs some cleanup.

isActive = false;
}

public async Task OnPostUpdateAsync(PostUpdateEvent @event, CancellationToken cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

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

Normally there is a no need to write this async method too. The async generator will do it for you too. Of course this means that at first your class will lack some interface method implementations and the project will not compile till you run the async generator, but this is the preferred way.

}
}

// Entity with ManyToOne type (Contact) with comnposite (ContactId) Id.
Copy link
Member

Choose a reason for hiding this comment

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

Typo on comnposite.

}


public class ContactIdentifier : IEquatable<ContactIdentifier>
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be marked serializable too?

}



Copy link
Member

Choose a reason for hiding this comment

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

Please clean the file from such consecutive blank lines.

@druidroad
Copy link
Contributor Author

druidroad commented Dec 28, 2017

I did cleanup and committed the changes:

  1. OnPostUpdateAsync was created using generator.
  2. Removed spaces.
  3. I didn't really need [Serializable] so I removed it.
  4. Fixed comments.

@fredericDelaporte fredericDelaporte self-assigned this Dec 29, 2017
@hazzik hazzik changed the title #1496 Fix ManyToOneType.IsModified to handle both object instance and… Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the “old” parameter Dec 29, 2017
@hazzik hazzik changed the title Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the “old” parameter Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the "old' parameter Dec 29, 2017
@hazzik hazzik changed the title Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the "old' parameter Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the "old" parameter Dec 29, 2017
@fredericDelaporte fredericDelaporte merged commit 72b9e1b into nhibernate:master Dec 30, 2017
@fredericDelaporte fredericDelaporte added this to the 5.1 milestone Dec 30, 2017
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.

Fix ManyToOneType.IsModified to handle both object instance and identifier passed to the parameter “old”.
2 participants