Skip to content
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

Remove persistent collections Equals/GetHashCode overrides #2461

Merged

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Jul 29, 2020

To make behavior consistent with standard collections.
Related to #2457

@bahusoid bahusoid changed the title Removed persistent collections Equals/GetHashCode overrides Remove persistent collections Equals/GetHashCode overrides Jul 29, 2020
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.

I am not convinced aligning with standard collections on this matter is worth the possible breaking change for application code currently relying on NHibernate Equals overrides for these collections.

As showcased by #2457, these overrides may cause in some cases failures, but it does not seem to be a frequently annoying pitfall, judging by the number of issues I have seen related to this. (#2457 is the first and only I have seen currently.)

(Due to this I am not decided on which type label it should have. Improvement? Task?)

@bahusoid
Copy link
Member Author

bahusoid commented Sep 1, 2020

I am not convinced aligning with standard collections on this matter is worth the possible breaking change for application code currently relying on NHibernate Equals overrides for these collections.

I'm pretty sure that the fact that Equals call make collection be eager loaded is not noticed by most users but it's not desired behavior for most of them. As it's stated in the issue - they have such problem for long time unnoticed and only fail shows them the issue.

Also this behavior is not consistent with our other persistent collections - for instance there is no override for bags.

Also the fact that behavior is different for persistent and transient entity is also disturbing.

Maybe Equals/GetHashcode methods really need to be overridden but with the following logic:
If it's initialized call Equals/GetHashcode on wrapped collection instead. If it's not - call reference equality.

But as first step - get rid of object equality where it's present I consider as good change anyway.

@fredericDelaporte
Copy link
Member

I'm pretty sure that the fact that Equals call makes collection be eager loaded is not noticed by most users but it's not desired behavior for most of them.

Well ok.

@hazzik hazzik merged commit 765e1ed into nhibernate:master Sep 6, 2020
@fredericDelaporte fredericDelaporte added this to the next minor milestone Sep 7, 2020
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.

3 participants