Skip to content

NH-3894 - Keys with custom GetHashCode are not added correctly to key-many-to-many/one-to-many dictionaries when FetchMode is not Select #1350

Open
@nhibernate-bot

Description

@nhibernate-bot

Martin Francisco created an issue — 3rd August 2016, 1:31:43:

When initializing a dictionary for a ternary relationship and the reference to the key in the element is mapped with either the default or join fetch mode, then the keys are added to the dictionary before they are fully hydrated (Id only).

This causes a problem when the key entity has a custom Equals/GetHashCode because the hash code will be incorrect until it is fully hydrated. This would either cause an exception if GetHashCode was expecting a valid fully hydrated state, or all related element entities are added to the same key (since all the keys were added with the default state GetHashCode value).

Attached are tests that show that all children are added to the same key when the dictionary is hydrated.

When the mapping is explicitly set to use select fetch mode, then the keys are fully hydrated before being added to the dictionary.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions