Nhibernate hasmany not updating funktionshinder dating
Hi, I'm having a problem with the mapping between to tables both having composite keys.
The error i get when trying to load the model configuration is this: Foreign key (FK8C35E6DA3F2FC42: Alternative Member [Id])) must have same number of columns as the referenced primary key (Attribute Member [Attribute Def Id, Object Def Id]) I can't change the tables so i have to make this work.
However, since the Media In Pool and Site Product already exist before the application tries to add a Media Product Presentation, the references could be read only as long as there was another way to tell NHibernate to update those ID fields.
The Solution The solution required changes to both the entity and the map.
They almost make building applications that use a relational database painless.
However, sometimes you run into something that costs a couple of developers the better part of a day and it makes you want to scream.
We wanted to eliminate those surrogate keys and use the combination of Site Id and Product Id as a composite key instead.
We had similar circumstances in a couple of other relationship tables that we also wanted to improve.
When NHibernate with Fluent NHibernate work, it’s a beautiful thing.I have attached a screen dump of the data model and the properties for the association NHibernate Designer generates except that when the association is generated it does not get a backreference name.All examples i have found deal with one of the joined tables having a composite key not both.If we make the reference to Media In Pool read only, the Media Id does not get set and the insert fails; If we make the Site Product reference read only, the insert fails with a null Site Id.A couple members of the team looked for solutions all afternoon.