Description
#1875 changed the way that duplicated column names were handled when generating insert and update statements. Prior to this change it was possible to map a column multiple times for a given object. When multiple many-to-one relationships exist that utilize one or more columns from the natural key for related objects an exception is now thrown from here:
I have a database that uses natural keys for related tables. While this breaking change is documented, there is no workable solution as individual columns of a many-to-one relationship cannot have insert
or update
set to false.
The issues with composite natural keys have been well known to cause inconsistent insert/updates if special care was not taken. In most cases there is no need to update the duplicated column from the many-to-one mappings and it is well understood that changing the column would also invalidate objects loaded using the original value. This problem has never really been addressed by NHibernate as surrogate keys are the preferred method for creating relationships.
This change put us and others in the precarious situation of doing one of the following:
- Creating a fork without this change
- Adding surrogate keys and redesigning an entire domain model.
An option to permit the old behavior should be added or individual columns of a many-to-one should be permitted to be read-only.