-
Notifications
You must be signed in to change notification settings - Fork 933
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
Conversation
…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.
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. |
I used Menubuilder to generate async method and tests.
DONE. Generated Async method with tests. See 98b1918 commit. |
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.
Looks good overall. Needs some cleanup.
isActive = false; | ||
} | ||
|
||
public async Task OnPostUpdateAsync(PostUpdateEvent @event, CancellationToken cancellationToken) |
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.
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. |
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.
Typo on comnposite
.
} | ||
|
||
|
||
public class ContactIdentifier : IEquatable<ContactIdentifier> |
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.
Shouldn't this be marked serializable too?
} | ||
|
||
|
||
|
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.
Please clean the file from such consecutive blank lines.
I did cleanup and committed the changes:
|
… identifier passed to the parameter “old”.
The tests
EventListener_Entity_ChangeProperty
andEventListener_EntityWithCompositeId_ChangeProperty
fail for current code inManyToOneType.IsModified(…)
whereold
parameter is not parsed.The tests
SelectBeforeUpdate_EntityWithCompositeId_ChangeProperty
andSelectBeforeUpdate_ManyToOneWithCompositeId_ChangeProperty
failif 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.