c# - Is there a sample why Equals/GetHashCode should be overwritten in NHibernate? -
I get lots of posts where it is explained that one should always override the same / gatehashcode on the NHibernate unit class . If I do not use the group, is it really necessary?
I can not get a sample only, where it is shown that the missing equivalent / gatehashcode can cause unexpected and incorrect behavior. It's strange that everyone says that it is necessary, but no one can provide a sample which why need it. Recently was selecting N + 1 about NHibernate, even if Any other similar answer links. Override edit You need to override them all the time is not. If you are using composite keys, multiple sessions may be required with different entities or stateless sessions. If you are working with only one session, then NHE Burnett stores the entities in the first level cache using an identity map. The unit of that case is compared by comparing the comparison ID. In the above cases (separate entity, Stateless session), NHBnet has compared the actual institutions, and not their ID by default, Contrary to the object, which is not defined by its features, but based on the thread of continuity and its identity The Zebus hibernate wiki has Fetch specified
same /
GetHashCode missing problem with the implementation.
equal /
GetHashCode here.
Object.Equals gives contextuality So two objects are the same, if they point to the exact same example. You can have two examples with the same identity, but
Object.Equals will return
false for them
entity :
equal and
hashcode with some code examples.
Comments
Post a Comment